public class AppSocket
extends java.lang.Object
Constructor and Description |
---|
AppSocket(Router r)
Constructs an AppSocket and binds it to any available port
on the local Router.
|
AppSocket(Router r,
Address addr,
int port)
Construct an AppSocket attached to the specified Router.
|
AppSocket(Router r,
int port)
Construct an AppSocket attached to the specified Router.
|
Modifier and Type | Method and Description |
---|---|
void |
bind(int port)
Binds this DatagramSocket to a port.
|
void |
close()
Close this socket.
|
void |
connect(Address address,
int port)
Connects the socket to a remote address for this socket.
|
void |
connect(SocketAddress sockaddr)
Connects the socket to a remote address for this socket.
|
void |
disconnect()
Disconnects the socket.
|
Address |
getLocalAddress()
Returns the address of the endpoint this socket is bound to,
or null if it is not bound yet.
|
int |
getLocalPort()
Returns the local port for this socket
to which this socket is bound.
|
int |
getPort()
Returns the remote port for this socket.
|
Address |
getRemoteAddress()
Returns the address to which this socket is connected.
|
int |
getSoTimeout()
Retrive setting for SO_TIMEOUT.
|
boolean |
isBound()
Returns the bound state of the socket.
|
boolean |
isClosed()
Returns the bound state of the socket.
|
boolean |
isConnected()
Returns the connection state of the socket.
|
Datagram |
receive()
Receives a datagram from this socket.
|
void |
send(Datagram dg)
Send a datagram from this socket.
|
void |
setSoTimeout(int timeout)
Enable/disable SO_TIMEOUT with the specified timeout, in
milliseconds.
|
java.lang.String |
toString()
toString.
|
public AppSocket(Router r) throws java.net.SocketException
java.net.SocketException
public AppSocket(Router r, int port) throws java.net.SocketException
java.net.SocketException
public AppSocket(Router r, Address addr, int port) throws java.net.SocketException
java.net.SocketException
public void bind(int port) throws java.net.SocketException
java.net.SocketException
public void connect(Address address, int port)
public void connect(SocketAddress sockaddr)
public int getPort()
public Address getRemoteAddress()
public boolean isConnected()
public boolean isBound()
public boolean isClosed()
public int getLocalPort()
public Address getLocalAddress()
public void send(Datagram dg) throws java.net.SocketException, java.net.NoRouteToHostException
java.net.SocketException
java.net.NoRouteToHostException
public Datagram receive() throws java.net.SocketException, SocketTimeoutException
java.net.SocketException
SocketTimeoutException
public void disconnect()
public void close()
public int getSoTimeout() throws java.net.SocketException
java.net.SocketException
public void setSoTimeout(int timeout) throws java.net.SocketException
java.net.SocketException
public java.lang.String toString()
toString
in class java.lang.Object
User Space Routing 0.10.3