DatagramSocket JavaScript is disabled on your browser. Overview Package Class Tree Deprecated Index Help Prev Class Next Class Frames No Frames All Classes Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method usr.net Class DatagramSocket java.lang.Object usr.net.DatagramSocket public class DatagramSocket
extends java.lang.Object A DatagramSocket looks similar to a Java DatagramSocket. It is intended to be a replacement for the Java version in order that apps can use USR for networking without too much effort in rewrites. Constructor Summary Constructors Constructor and Description DatagramSocket() Create a DatagramSocket bound to a a free port. DatagramSocket(Address addr, int port) Create a DatagramSocket connected to a specified remote Address and port. DatagramSocket(int port) Create a DatagramSocket bound to a port. Method Summary Methods 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. Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait Constructor Detail DatagramSocket public DatagramSocket()
throws java.net.SocketException Create a DatagramSocket bound to a a free port. Throws: java.net.SocketException DatagramSocket public DatagramSocket(int port)
throws java.net.SocketException Create a DatagramSocket bound to a port. Throws: java.net.SocketException DatagramSocket public DatagramSocket(Address addr,
int port)
throws java.net.SocketException Create a DatagramSocket connected to a specified remote Address and port. Throws: java.net.SocketException Method Detail bind public void bind(int port)
throws java.net.SocketException Binds this DatagramSocket to a port. Throws: java.net.SocketException connect public void connect(SocketAddress sockaddr) Connects the socket to a remote address for this socket. When a socket is connected to a remote address, packets may only be sent to or received from that address. By default a datagram socket is not connected. connect public void connect(Address address,
int port) Connects the socket to a remote address for this socket. When a socket is connected to a remote address, packets may only be sent to or received from that address. By default a datagram socket is not connected. getPort public int getPort() Returns the remote port for this socket. Returns -1 if the socket is not connected. getRemoteAddress public Address getRemoteAddress() Returns the address to which this socket is connected. Returns null if the socket is not connected. isConnected public boolean isConnected() Returns the connection state of the socket. Returns: true if the socket succesfuly connected to a server isBound public boolean isBound() Returns the bound state of the socket. Returns: true if the socket succesfuly bound to an address isClosed public boolean isClosed() Returns the bound state of the socket. Returns: true if the socket is closed. getLocalPort public int getLocalPort() Returns the local port for this socket to which this socket is bound. getLocalAddress public Address getLocalAddress() Returns the address of the endpoint this socket is bound to, or null if it is not bound yet. send public void send(Datagram dg)
throws java.net.SocketException,
java.net.NoRouteToHostException Send a datagram from this socket. The Datagram includes information indicating the data to be sent, its length, the address of the remote router, and the port number on the remote router. Throws: java.net.SocketException java.net.NoRouteToHostException receive public Datagram receive()
throws java.net.SocketException,
SocketTimeoutException Receives a datagram from this socket. When this method returns, the Datagram is filled with the data received. The datagram also contains the sender's address, and the port number on the sender's machine. This method blocks until a datagram is received. Throws: java.net.SocketException SocketTimeoutException close public void close() Close this socket. disconnect public void disconnect() Disconnects the socket. This does nothing if the socket is not connected. getSoTimeout public int getSoTimeout()
throws java.net.SocketException Retrive setting for SO_TIMEOUT. 0 returns implies that the option is disabled (i.e., timeout of infinity). Throws: java.net.SocketException setSoTimeout public void setSoTimeout(int timeout)
throws java.net.SocketException Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a call to receive() for this DatagramSocket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the DatagramSocket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Parameters: timeout - the specified timeout in milliseconds. Throws: java.net.SocketException toString public java.lang.String toString() toString. Overrides: toString in class java.lang.Object Overview Package Class Tree Deprecated Index Help Prev Class Next Class Frames No Frames All Classes Summary: Nested | Field | Constr | Method Detail: Field | Constr | Method User Space Routing 0.10.3