org.kwis.msf.io
Interface Socket


public interface Socket

플랫폼 외부와의 데이타 통신을 가능하게 하는 클래스이다.

소켓은 stream 소켓과 그렇지 않은 소켓으로 구분된다. stream 소켓은 InputStream 과 OutputStream 으로 통신을 하며 stream 소켓이 아닌 경우는 메세지(Message) 오브젝트를 가지고 통신을 한다. stream 소켓의 대표적인 예가 TCP 통신을 하는 소켓이고 메세지 통신을 하는 소켓의 대표적인 예가 UDP 통신을 하는 소켓이다.


Method Summary
 Socket accept()
          서버 기능을 지원하는 소켓이 새롭게 연결된 소켓을 리턴한다.
 void close()
          소켓을 닫는다. stream 소켓일 경우 만약 getInputStream() 이나 getOutputStream() 으로 InputStream 혹은 OutputStream 을 리턴한 경우 소켓이 완전히 닫히기 위해서는 이 메쏘드와 함께 InputStream 혹은 OutputStream 의 close() 메쏘드가 불려 져야 한다.
 InputStream getInputStream()
          stream 소켓일 경우 InputStream 을 리턴한다.
 int getMessageCount()
          stream 소켓이 아닐 경우 앞으로 이 소켓으로 부터 읽을 수 있는 메세지 갯수를 알려준다.
 int getMessageMaxLength()
          stream 소켓이 아닐경우 한 메세지에 실을 수 있는 데이타의 최대길이를 알려준다.
 OutputStream getOutputStream()
          stream 소켓일 경우 OutputStream 을 리턴한다.
 boolean isStream()
          stream 소켓인지여부를 알려준다.
 void recv(Message m)
          stream 소켓이 아닐 경우 메세지를 수신한다.
 void send(Message m)
          stream 소켓이 아닐 경우 메세지를 전송한다.
 

Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
stream 소켓일 경우 InputStream 을 리턴한다.
Returns:
InputStream 을 리턴한다
Throws:
IOException - stream 소켓이 아니거나 InputStream 을 리턴하지 못할 경우

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
stream 소켓일 경우 OutputStream 을 리턴한다.
Returns:
OutputStream 을 리턴한다
Throws:
IOException - stream 소켓이 아니거나 OutputStream 을 리턴하지 못할 경우

isStream

public boolean isStream()
stream 소켓인지여부를 알려준다.
Returns:
stream 소켓이면 true, 아니면 false

getMessageCount

public int getMessageCount()
                    throws IOException
stream 소켓이 아닐 경우 앞으로 이 소켓으로 부터 읽을 수 있는 메세지 갯수를 알려준다.
Returns:
앞으로 읽을 수 있는 메세지 갯수. 메세지 갯수를 알수 없을 경우
-1을 리턴한다.
Throws:
IOException - stream 소켓일 경우

getMessageMaxLength

public int getMessageMaxLength()
                        throws IOException
stream 소켓이 아닐경우 한 메세지에 실을 수 있는 데이타의 최대길이를 알려준다.
Returns:
메세지 데이타의 최대길이
Throws:
IOException - stream 소켓일 경우

send

public void send(Message m)
          throws IOException
stream 소켓이 아닐 경우 메세지를 전송한다.
Throws:
IOException - stream 소켓이거나 메세지를 전송하지 못할 경우

recv

public void recv(Message m)
          throws IOException
stream 소켓이 아닐 경우 메세지를 수신한다.
Parameters:
m - 수신된 데이타가 저장될 메세지 버퍼
Throws:
IOException - stream 소켓이거나 메세지를 수신하지 못할 경우

close

public void close()
           throws IOException
소켓을 닫는다. stream 소켓일 경우 만약 getInputStream() 이나 getOutputStream() 으로 InputStream 혹은 OutputStream 을 리턴한 경우 소켓이 완전히 닫히기 위해서는 이 메쏘드와 함께 InputStream 혹은 OutputStream 의 close() 메쏘드가 불려 져야 한다.
Throws:
IOException - 에러 발생시

accept

public Socket accept()
              throws IOException
서버 기능을 지원하는 소켓이 새롭게 연결된 소켓을 리턴한다.
Returns:
새로 연결된 소켓
Throws:
IOException - 서버 기능을 지원하는 소켓이 아니거나 I/O 에러가 발생할 경우


AromaSoft Corp. Proprietary and Confidential

(C)opyright 2003 AromaSoft Corp. All right reserved.
Contact : contact@aromasoft.com