|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.DatagramMessage
public class DatagramMessage
A class for sending and recieving datagram messages [CHECK]
Field Summary | |
---|---|
protected java.net.DatagramSocket |
datagramSocket
|
protected java.net.DatagramPacket |
recvPacket
|
protected java.net.DatagramPacket |
sendPacket
|
Constructor Summary | |
---|---|
protected |
DatagramMessage()
For subclassing only |
|
DatagramMessage(java.net.InetAddress destHost,
int destPort)
Constructor for sending messages |
|
DatagramMessage(java.net.InetAddress destHost,
int destPort,
int bindPort)
Constructor for sending messages |
|
DatagramMessage(java.net.InetAddress destHost,
int destPort,
int bindPort,
java.net.InetAddress bindAddr)
Constructor for sending messages |
|
DatagramMessage(int port)
Constructor for receiving messages |
|
DatagramMessage(java.lang.String destHost,
int destPort)
Constructor for sending messages |
|
DatagramMessage(java.lang.String destHost,
int destPort,
int bindPort)
Constructor for sending messages |
|
DatagramMessage(java.lang.String destHost,
int destPort,
int bindPort,
java.lang.String bindAddr)
Constructor for sending messages |
Method Summary | |
---|---|
void |
close()
Closes the datagram socket |
java.net.DatagramPacket |
getReceivePacket()
Gets the DatagramPacket last recieved [CHECK] |
java.net.DatagramPacket |
getSendPacket()
Gets the datagram packet to be sent |
static void |
main(java.lang.String[] argv)
Main entry point for testing/debugging |
byte[] |
receive(int maxBuffSize)
Receive an array of bytes |
void |
send(byte[] data)
Send an array of bytes to the remote host |
void |
send(byte[] data,
int len)
Send an array of bytes to the remote host |
void |
send(byte[] data,
int len,
int count)
Send an array of bytes to the remote host |
void |
send(java.lang.String msg)
Send a String to the remote host |
void |
setRemoteHost(java.net.InetAddress host,
int port)
Set the remote(destination) host |
void |
setRemoteHost(java.lang.String host,
int port)
Set the remote(destination) host |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.net.DatagramSocket datagramSocket
protected java.net.DatagramPacket sendPacket
protected java.net.DatagramPacket recvPacket
Constructor Detail |
---|
protected DatagramMessage()
public DatagramMessage(int port) throws java.io.IOException, java.net.UnknownHostException
port
- The port to use
java.io.IOException
- if a socket error occurs
java.net.UnknownHostException
- if the IP adress of the host could not be
determinedpublic DatagramMessage(java.lang.String destHost, int destPort) throws java.io.IOException, java.net.UnknownHostException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to use
java.io.IOException
- if a socket error occurs
java.net.UnknownHostException
- if the IP adress of the host could not be
determinedpublic DatagramMessage(java.net.InetAddress destHost, int destPort) throws java.io.IOException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to use
java.io.IOException
- if a socket error occurspublic DatagramMessage(java.lang.String destHost, int destPort, int bindPort) throws java.io.IOException, java.net.UnknownHostException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to usebindPort
- The local port to bind
java.io.IOException
- if a socket error occurs
java.net.UnknownHostException
- if the IP adress of the host could not be
determinedpublic DatagramMessage(java.lang.String destHost, int destPort, int bindPort, java.lang.String bindAddr) throws java.io.IOException, java.net.UnknownHostException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to usebindPort
- The local port to bindbindAddr
- The local address to bind
java.io.IOException
- if a socket error occurs
java.net.UnknownHostException
- if the IP adress of the host could not be
determinedpublic DatagramMessage(java.net.InetAddress destHost, int destPort, int bindPort) throws java.io.IOException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to usebindPort
- The local port to bind
java.io.IOException
- if a socket error occurspublic DatagramMessage(java.net.InetAddress destHost, int destPort, int bindPort, java.net.InetAddress bindAddr) throws java.io.IOException
destHost
- The remote(destination) host addressdestPort
- The remote(destination) port to usebindPort
- The local port to bindbindAddr
- The local address to bind
java.io.IOException
- if a socket error occursMethod Detail |
---|
public void close() throws java.io.IOException
java.io.IOException
public void setRemoteHost(java.lang.String host, int port) throws java.io.IOException
host
- The remote host addressport
- The remote host port
java.io.IOException
- if an error occurspublic void setRemoteHost(java.net.InetAddress host, int port) throws java.io.IOException
host
- The remote host addressport
- The remote host port
java.io.IOException
- if an error occurspublic java.net.DatagramPacket getSendPacket()
public void send(java.lang.String msg) throws java.io.IOException
msg
- The String to send to the remote host
java.io.IOException
- if the string is null or a socket error occurspublic void send(byte[] data) throws java.io.IOException
data
- The array of bytes to send to the remote host
java.io.IOException
- if the string is null or a socket error occurspublic void send(byte[] data, int len) throws java.io.IOException
data
- The array of bytes to send to the remote hostlen
- The length of the data
java.io.IOException
- if the string is null or a socket error occurspublic void send(byte[] data, int len, int count) throws java.io.IOException
data
- The array of bytes to send to the remote hostlen
- The length of the datacount
- The number of times to send the message
java.io.IOException
- if the string is null or a socket error occurspublic byte[] receive(int maxBuffSize) throws java.io.IOException
maxBuffSize
- The maximum buffer size
java.io.IOException
- if a socket error occurspublic java.net.DatagramPacket getReceivePacket()
public static void main(java.lang.String[] argv)
argv
- Comand-line arguments
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |