Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.net

Class DatagramSocketImpl

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

All Implemented Interfaces:

SocketOptions


public abstract class DatagramSocketImpl

extends Object

implements SocketOptions

This abstract class models a datagram socket implementation. An actual implementation class would implement these methods, probably via redirecting them to native code.

Written using on-line Java Platform 1.2 API Specification, as well as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).

Status: Believed complete and correct.

Since:Authors:

Field Summary

java.io.FileDescriptorfd

The FileDescriptor object for this object.
intlocalPort

The local port to which this socket is bound

Constructor Summary

DatagramSocketImpl()

Default, no-argument constructor for subclasses to call.

Method Summary

voidbind(int lport, java.net.InetAddress laddr)

This method binds the socket to the specified local port and address.
voidclose()

This methods closes the socket
voidconnect(java.net.InetAddress address, int port)

Connects the socket to a host specified by address and port.
voidcreate()

Creates a new datagram socket.
voiddisconnect()

Disconnects the socket.
java.io.FileDescriptorgetFileDescriptor()

Returns the FileDescriptor for this socket
intgetLocalPort()

Returns the local port this socket is bound to
java.lang.ObjectgetOption(int option_id)

Returns the current setting of the specified option.
bytegetTTL()

This method returns the current Time to Live (TTL) setting on this socket.
intgetTimeToLive()

This method returns the current Time to Live (TTL) setting on this socket.
voidjoin(java.net.InetAddress inetaddr)

Causes this socket to join the specified multicast group
voidjoinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Causes this socket to join the specified multicast group on a specified device
voidleave(java.net.InetAddress inetaddr)

Causes the socket to leave the specified multicast group.
voidleaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Leaves a multicast group
intpeek(java.net.InetAddress i)

Takes a peek at the next packet received in order to retrieve the address of the sender
intpeekData(java.net.DatagramPacket p)

Takes a peek at the next packet received.
voidreceive(java.net.DatagramPacket p)

Receives a packet of data from the network Will block until a packet arrives.
voidsend(java.net.DatagramPacket p)

Transmits the specified packet of data to the network.
voidsetOption(int option_id, java.lang.Object val)

Sets the specified option on a socket to the passed in object.
voidsetTTL(byte ttl)

Sets the Time to Live (TTL) setting on this socket to the specified value.
voidsetTimeToLive(int ttl)

Sets the Time to Live (TTL) setting on this socket to the specified value.

Field Details

fd

protected FileDescriptor fd

The FileDescriptor object for this object.


localPort

protected int localPort

The local port to which this socket is bound


Constructor Details

DatagramSocketImpl

public DatagramSocketImpl()

Default, no-argument constructor for subclasses to call.


Method Details

bind

protected void bind(int lport, java.net.InetAddress laddr)

This method binds the socket to the specified local port and address.

Parameters:

Throws:


close

protected void close()

This methods closes the socket


connect

protected void connect(java.net.InetAddress address, int port)

Connects the socket to a host specified by address and port.

Since:Parameters:

Throws:


create

protected void create()

Creates a new datagram socket.

Throws:


disconnect

protected void disconnect()

Disconnects the socket.

Since:

getFileDescriptor

protected FileDescriptor getFileDescriptor()

Returns the FileDescriptor for this socket


getLocalPort

protected int getLocalPort()

Returns the local port this socket is bound to


getOption

public Object getOption(int option_id)

Returns the current setting of the specified option. The Object returned will be an Integer for options that have integer values. For options that are set to on or off, a Boolean will be returned. The option_id is one of the defined constants in the superinterface.

Parameters:

Returns:

Throws:


getTTL

protected byte getTTL()

This method returns the current Time to Live (TTL) setting on this socket. Use getTimeToLive() instead.

Throws:


getTimeToLive

protected int getTimeToLive()

This method returns the current Time to Live (TTL) setting on this socket.

Throws:


join

protected void join(java.net.InetAddress inetaddr)

Causes this socket to join the specified multicast group

Parameters:

Throws:


joinGroup

protected void joinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Causes this socket to join the specified multicast group on a specified device

Since:Parameters:

Throws:


leave

protected void leave(java.net.InetAddress inetaddr)

Causes the socket to leave the specified multicast group.

Parameters:

Throws:


leaveGroup

protected void leaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)

Leaves a multicast group

Since:Parameters:

Throws:


peek

protected int peek(java.net.InetAddress i)

Takes a peek at the next packet received in order to retrieve the address of the sender

Parameters:

Returns:

Throws:


peekData

protected int peekData(java.net.DatagramPacket p)

Takes a peek at the next packet received. This packet is not consumed. With the next peekData/receive operation this packet will be read again.

Since:Parameters:

Returns:

Throws:


receive

protected void receive(java.net.DatagramPacket p)

Receives a packet of data from the network Will block until a packet arrives. The packet info in populated into the passed in DatagramPacket object.

Parameters:

Throws:


send

protected void send(java.net.DatagramPacket p)

Transmits the specified packet of data to the network. The destination host and port should be encoded in the packet.

Parameters:

Throws:


setOption

public void setOption(int option_id, java.lang.Object val)

Sets the specified option on a socket to the passed in object. For options that take an integer argument, the passed in object is an Integer. For options that are set to on or off, the value passed will be a Boolean. The option_id parameter is one of the defined constants in the superinterface.

Parameters:

Throws:


setTTL

protected void setTTL(byte ttl)

Sets the Time to Live (TTL) setting on this socket to the specified value. Use setTimeToLive(int) instead.

Parameters:

Throws:


setTimeToLive

protected void setTimeToLive(int ttl)

Sets the Time to Live (TTL) setting on this socket to the specified value.

Parameters:

Throws: