java.net
Class DatagramSocket

java.lang.Object
  |
  +--java.net.DatagramSocket

public class DatagramSocket
extends Object

The datagram socket class implements unreliable datagrams.


Constructor Summary
DatagramSocket()
          Creates a datagram socket
DatagramSocket(int port)
          Creates a datagram socket
 
Method Summary
 void close()
          Close the datagram socket.
protected  void finalize()
          Code to perform when this object is garbage collected.
 int getLocalPort()
          Returns the local port that this socket is bound to.
 void receive(DatagramPacket p)
          Receives datagram packet.
 void send(DatagramPacket p)
          Sends Datagram Packet to the destination address
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatagramSocket

public DatagramSocket()
               throws SocketException
Creates a datagram socket


DatagramSocket

public DatagramSocket(int port)
               throws SocketException
Creates a datagram socket

Method Detail

send

public void send(DatagramPacket p)
          throws IOException
Sends Datagram Packet to the destination address

Throws:
IOException - i/o error occurred

receive

public void receive(DatagramPacket p)
             throws IOException
Receives datagram packet.

Throws:
IOException - i/o error occurred

getLocalPort

public int getLocalPort()
Returns the local port that this socket is bound to.


close

public void close()
Close the datagram socket.


finalize

protected void finalize()
Description copied from class: Object
Code to perform when this object is garbage collected. The default is that nothing needs to be performed. Any exception thrown by a finalize method causes the finalization to halt. But otherwise, it is ignored.

Overrides:
finalize in class Object