|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--omnisockets.OmniSocket
The OmniSocket class is a socket that runs itself in a thread, then when a message is received creates and runs an OmniMessage of the appropriate type. This relives you from having to develop program logic to receive messages, unmarshall message data and handle the message. On the send side, you simply create an Omni Message of some type, fill in its fields appropriately and call OmniSocket.send(). The message data is automatically marshalled and sent on the socket.
OmniMessage
Constructor Summary | |
OmniSocket(java.net.InetAddress inaddr,
int port)
Constructs an OmniSocket for IP addr:port. |
|
OmniSocket(java.net.InetAddress inaddr,
int port,
omnisockets.OmniEventHandler eventHandler)
Constructs an OmniSocket for IP addr:port. |
|
OmniSocket(java.net.Socket socket)
Constructs an OmniSocket for a vanilla socket. |
|
OmniSocket(java.net.Socket socket,
omnisockets.OmniEventHandler eventHandler)
Constructs an OmniSocket for a vanilla socket. |
|
OmniSocket(java.lang.String hostname,
int port)
Constructs an OmniSocket for hostname:port. |
|
OmniSocket(java.lang.String hostname,
int port,
omnisockets.OmniEventHandler eventHandler)
Constructs an OmniSocket for hostname:port. |
Method Summary | |
void |
close()
Closes the socket. |
boolean |
equals(omnisockets.OmniSocket s)
Tests if this sockets is equal to another by comparing their hash codes. |
omnisockets.OmniEventHandler |
getEventHandler()
Returns the event handler. |
omnisockets.OmniListener |
getListener()
Returns the listener. |
java.lang.String |
getLocalHost()
Returns the bind address. |
int |
getLocalPort()
Returns the local port. |
omnisockets.OmniMessage |
getMessage()
Returns the current message. |
java.net.Socket |
getRawSocket()
Returns the raw socket. |
java.net.InetAddress |
getRemoteHost()
Returns the remote IP address. |
int |
getRemotePort()
Returns the remote port. |
java.lang.Thread |
getThread()
Returns the thread. |
int |
hashCode()
Returns a distinct integer for distinct OmniSockets. |
boolean |
isConnected()
Returns the connection state of the socket. |
void |
run()
Runs the message dispatcher. |
void |
send(omnisockets.OmniMessage message)
Sends the message on the socket. |
void |
setEventHandler(omnisockets.OmniEventHandler eventHandler)
Sets the event handler. |
void |
setKeepAlive(boolean on)
Enable/disable SO_KEEPALIVE. |
void |
setListener(omnisockets.OmniListener listener)
Sets the listener. |
void |
setMessage(omnisockets.OmniMessage message)
Sets the current message. |
void |
setName(java.lang.String name)
Sets the socket name. |
void |
setPriority(int priority)
Sets the socket priority. |
void |
setSendBufferSize(int size)
Sets the SO_SNDBUF option to the specified value for this Socket. |
void |
setSoLinger(boolean on,
int linger)
Enable/disable SO_LINGER with the specified linger time in seconds. |
void |
setTcpNoDelay(boolean on)
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm). |
Methods inherited from class java.lang.Object |
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public OmniSocket(java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for hostname:port.
hostname
- the remote host nameport
- the remote port numberpublic OmniSocket(java.lang.String hostname, int port, omnisockets.OmniEventHandler eventHandler) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for hostname:port.
hostname
- the remote host nameport
- the remote port numberpublic OmniSocket(java.net.InetAddress inaddr, int port) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for IP addr:port.
port
- the remote port numberpublic OmniSocket(java.net.InetAddress inaddr, int port, omnisockets.OmniEventHandler eventHandler) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for IP addr:port.
port
- the remote port numberpublic OmniSocket(java.net.Socket socket) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for a vanilla socket.
socket
- a connected Socket for use as a message streampublic OmniSocket(java.net.Socket socket, omnisockets.OmniEventHandler eventHandler) throws java.net.UnknownHostException, java.io.IOException
OmniSocket
for a vanilla socket.
socket
- a connected Socket for use as a message streamMethod Detail |
public void run()
run
in interface java.lang.Runnable
public void send(omnisockets.OmniMessage message) throws java.io.NotSerializableException, java.io.IOException
message
- the OmniMessage to send
java.io.NotSerializableException
java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
public java.net.InetAddress getRemoteHost()
public int getRemotePort()
public java.lang.String getLocalHost()
public int getLocalPort()
public omnisockets.OmniListener getListener()
public void setListener(omnisockets.OmniListener listener)
public omnisockets.OmniEventHandler getEventHandler()
public void setEventHandler(omnisockets.OmniEventHandler eventHandler)
public omnisockets.OmniMessage getMessage()
public void setMessage(omnisockets.OmniMessage message)
public boolean isConnected()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(omnisockets.OmniSocket s)
public void setPriority(int priority)
priority
- a valid thread prioritypublic void setName(java.lang.String name)
name
- a descriptive stringpublic java.lang.Thread getThread()
public void setTcpNoDelay(boolean on) throws java.net.SocketException
java.net.SocketException
- if there is an error
in the underlying protocol, such as a TCP error.public void setSoLinger(boolean on, int linger) throws java.net.SocketException
on
- whether or not to linger on.linger
- how long to linger for, if on is true.
java.net.SocketException
- if there is an error
in the underlying protocol, such as a TCP error.
java.lang.IllegalArgumentException
- if the linger value is negative.public void setSendBufferSize(int size) throws java.net.SocketException
size
- the size to which to set the send buffer
size. This value must be greater than 0.
java.net.SocketException
- if there is an error
in the underlying protocol, such as a TCP error.
java.lang.IllegalArgumentException
- if the
value is 0 or is negative.public void setKeepAlive(boolean on) throws java.net.SocketException
on
- whether or not to have socket keep alive turned on.
java.net.SocketException
- if there is an error
in the underlying protocol, such as a TCP error.public java.net.Socket getRawSocket()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |