|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.net.Socket
seda.nbio.NonblockingSocket
public class NonblockingSocket
A NonblockingSocket is a socket which exports nonblocking input/output
streams. It is otherwise idential to a standard socket.
Socket connection can be either blocking or nonblocking. Use of the
standard constructors causes the current thread to block until
the connection is established. Otherwise, there are 3 ways to check
if the connection has been established:
(1) Call finishConnection
,
(2) Call connectDone
, or
(3) Create a SelectSet
and select on the event
Selectable.CONNECT_READY
, then call connectDone
.
SelectSet
Field Summary | |
---|---|
(package private) NonblockingSocketImpl |
impl
|
(package private) boolean |
is_connected
|
(package private) static boolean |
nativeLibraryLoaded
|
(package private) static java.lang.Object |
nativeLibraryLoadLock
|
Fields inherited from interface seda.nbio.Selectable |
---|
ACCEPT_READY, CONNECT_READY, READ_READY, SELECT_ERROR, WRITE_READY |
Constructor Summary | |
---|---|
NonblockingSocket()
|
|
NonblockingSocket(java.net.InetAddress address,
int port)
Create a NonblockingSocket connection to the given host and port number. |
|
NonblockingSocket(java.net.InetAddress address,
int port,
boolean block)
Create a NonblockingSocket connection to the given host and port number. |
|
NonblockingSocket(java.lang.String host,
int port)
Create a NonblockingSocket connection to the given host and port number. |
|
NonblockingSocket(java.lang.String host,
int port,
boolean block)
Create a NonblockingSocket connection to the given host and port number. |
Method Summary | |
---|---|
void |
close()
Closes the socket. |
boolean |
connectDone()
Indicate whether the connection on this socket has been established. |
boolean |
finishConnect(int timeout)
Block until the connection on this socket has been established. |
java.net.InetAddress |
getInetAddress()
Return the remote address to which this socket is bound. |
java.io.InputStream |
getInputStream()
Return an InputStream from which data on this socket can be read. |
java.net.InetAddress |
getLocalAddress()
Return the local address to which this socket is bound. |
int |
getLocalPort()
Return the local port to which this socket is bound. |
java.io.OutputStream |
getOutputStream()
Return an OutputStream to which data on this socket can be written. |
int |
getPort()
Return the remote port to which this socket is bound. |
int |
getSoLinger()
Currently unimplemented. |
int |
getSoTimeout()
Currently unimplemented. |
boolean |
getTcpNoDelay()
Currently unimplemented. |
(package private) static void |
loadNativeLibrary()
|
void |
setSoLinger(boolean on,
int val)
Currently unimplemented. |
void |
setSoTimeout(int timeout)
Currently unimplemented. |
void |
setTcpNoDelay(boolean on)
Currently unimplemented. |
java.lang.String |
toString()
|
Methods inherited from class java.net.Socket |
---|
bind, connect, connect, getChannel, getKeepAlive, getLocalSocketAddress, getOOBInline, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, sendUrgentData, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSocketImplFactory, setTrafficClass, shutdownInput, shutdownOutput |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
NonblockingSocketImpl impl
boolean is_connected
static boolean nativeLibraryLoaded
static java.lang.Object nativeLibraryLoadLock
Constructor Detail |
---|
NonblockingSocket() throws java.io.IOException
java.io.IOException
public NonblockingSocket(java.lang.String host, int port) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public NonblockingSocket(java.lang.String host, int port, boolean block) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public NonblockingSocket(java.net.InetAddress address, int port) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public NonblockingSocket(java.net.InetAddress address, int port, boolean block) throws java.io.IOException
java.io.IOException
Method Detail |
---|
static void loadNativeLibrary()
public boolean finishConnect(int timeout) throws java.net.SocketException
connectDone
). A timeout of -1
causes this call to block indefinitely until the connection is
established.
java.net.SocketException
public boolean connectDone() throws java.net.SocketException
java.net.SocketException
public java.net.InetAddress getInetAddress()
getInetAddress
in class java.net.Socket
public java.net.InetAddress getLocalAddress()
getLocalAddress
in class java.net.Socket
public int getPort()
getPort
in class java.net.Socket
public int getLocalPort()
getLocalPort
in class java.net.Socket
public java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in class java.net.Socket
java.io.IOException
public java.io.OutputStream getOutputStream() throws java.io.IOException
getOutputStream
in class java.net.Socket
java.io.IOException
public void setTcpNoDelay(boolean on) throws java.net.SocketException
setTcpNoDelay
in class java.net.Socket
java.net.SocketException
public boolean getTcpNoDelay() throws java.net.SocketException
getTcpNoDelay
in class java.net.Socket
java.net.SocketException
public void setSoLinger(boolean on, int val) throws java.net.SocketException
setSoLinger
in class java.net.Socket
java.net.SocketException
public int getSoLinger() throws java.net.SocketException
getSoLinger
in class java.net.Socket
java.net.SocketException
public void setSoTimeout(int timeout) throws java.net.SocketException
setSoTimeout
in class java.net.Socket
java.net.SocketException
public int getSoTimeout() throws java.net.SocketException
getSoTimeout
in class java.net.Socket
java.net.SocketException
public void close() throws java.io.IOException
close
in class java.net.Socket
java.io.IOException
public java.lang.String toString()
toString
in class java.net.Socket
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |