Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.net
Class DatagramSocket

    java.lang.Object
      jcontrol.net.DatagramSocket

    public class DatagramSocket

extends Object

JControl UDP Socket Implementation This class represents a socket for sending and receiving datagram packets. A datagram socket is the sending or receiving point for a packet delivery service. Each packet sent or received on a datagram socket is individually addressed and routed. Multiple packets sent from one machine to another may be routed differently, and may arrive in any order. UDP broadcasts sends are always enabled on a DatagramSocket. In order to receive broadcast packets a DatagramSocket should be bound to the wildcard address. In some implementations, broadcast packets may also be received when a DatagramSocket is bound to a more specific address.

Method Summary
`void` | `close()` Closes this UDP socket
`static DatagramSocket` | `create(int port)` Creates a new UDP socket by overgiven port-number on the local machine.
`protected void` | `finalize()` Free internal data structures used by this datagramsocket object.
`int` | `getLocalPort()` Returns the port number on the local host to which this socket is bound.
`void` | `receive(DatagramPacket p)` Receives a datagram packet from this socket.
`void` | `send(DatagramPacket p)` Sends a datagram packet from this socket.

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Method Detail

### getLocalPort

    public int getLocalPort()

  Returns the port number on the local host to which this socket is bound.

  Returns:
    the port number on the local host to which this socket is bound.

### create

    public static DatagramSocket create(int port)
                                 throws IOException

  Creates a new UDP socket by overgiven port-number on the local machine.

  Parameters:
    `port` - local port number
  Returns:
    UDP socket
  Throws:
    `IOException` - if error occured

### send

    public void send(DatagramPacket p)
              throws IOException

  Sends a datagram packet from this socket. The DatgramPacket contains the bytes to send, the target's IP address, and the port number on the target's machine.

  Parameters:
    `p` - DatagramPacket contains target UDP header informations and data to send.
  Throws:
    `IOException` - if error occured

### receive

    public void receive(DatagramPacket p)
                 throws IOException

  Receives a datagram packet from this socket. When this method returns, the data is filled with the data received. The DatgramPacket contains the received bytes, the number of received bytes, the sender's IP address, and the port number on the sender's machine.

  Parameters:
    `p` - DatagramPacket to store the received UDP header informations and data.
  Throws:
    `IOException` - if error occured

### close

    public void close()
               throws IOException

  Closes this UDP socket

  Throws:
    `IOException` - if error occured or DatagramSocket always closed

### finalize

    protected void finalize()

  Free internal data structures used by this datagramsocket object.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD