public class StandardSocket extends java.lang.Object implements ContextSocketFace
DatagramSocket
Constructor and Description |
---|
StandardSocket() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this socket.
|
void |
create(int port,
java.lang.String bindAddr)
Creates the socket.
|
void |
create(java.lang.String host,
int port,
java.lang.String bindAddr)
Creates the socket.
|
java.lang.String |
getLocalSocketAddress()
Returns the address of the endpoint this socket is bound to, or null
if it is not bound yet.
|
java.lang.String |
getReceivedFromHostAddress()
Returns the IP address of the (latest) host of the packet we received.
|
java.lang.String |
getRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or
null if it is unconnected.
|
java.lang.String |
getSendToHostAddress()
Returns the IP address of the host we sent the packet to.
|
StreamPortItem |
receive(int maxRecvSize)
Receives a packet from this socket.
|
void |
send(byte[] packet)
Sends a packet from this socket.
|
public void create(int port, java.lang.String bindAddr) throws java.io.IOException
ContextSocketFace
create
in interface ContextSocketFace
port
- The local port number were we receive (listen for)
packetsbindAddr
- The local address the server will bind to when
listeningjava.io.IOException
ContextSocketFace.create(String, int, String)
public void create(java.lang.String host, int port, java.lang.String bindAddr) throws java.io.IOException
ContextSocketFace
create
in interface ContextSocketFace
host
- The name of the host that is to receive our packetsport
- The port number of the hostbindAddr
- The local address the server will bind to when
sending packetsjava.io.IOException
ContextSocketFace.create(int, String)
public java.lang.String getReceivedFromHostAddress()
ContextSocketFace
getReceivedFromHostAddress
in interface ContextSocketFace
ContextSocketFace.getSendToHostAddress()
public java.lang.String getSendToHostAddress()
ContextSocketFace
getSendToHostAddress
in interface ContextSocketFace
ContextSocketFace.getReceivedFromHostAddress()
public java.lang.String getLocalSocketAddress()
ContextSocketFace
getLocalSocketAddress
in interface ContextSocketFace
public java.lang.String getRemoteSocketAddress()
ContextSocketFace
getRemoteSocketAddress
in interface ContextSocketFace
public StreamPortItem receive(int maxRecvSize) throws java.io.IOException
ContextSocketFace
receive
in interface ContextSocketFace
maxRecvSize
- the maximum number of bytes to receivejava.io.IOException
public void send(byte[] packet) throws java.io.IOException
ContextSocketFace
send
in interface ContextSocketFace
packet
- the packetjava.io.IOException
public void close()
ContextSocketFace
close
in interface ContextSocketFace