java.net
public
abstract
class
java.net.DatagramSocketImpl
The abstract superclass of datagram & multicast socket implementations.
Summary
IP_MULTICAST_IF,
IP_MULTICAST_IF2,
IP_MULTICAST_LOOP,
IP_TOS,
SO_BINDADDR,
SO_BROADCAST,
SO_KEEPALIVE,
SO_LINGER,
SO_OOBINLINE,
SO_RCVBUF,
SO_REUSEADDR,
SO_SNDBUF,
SO_TIMEOUT,
TCP_NODELAY
Fields
Public Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Fields
Public Constructors
public
DatagramSocketImpl()
Constructs an unbound datagram socket implementation.
Public Methods
public
abstract
Object
getOption(int optID)
Answer the nominated socket option.
Parameters
optID
| the socket option to retrieve |
public
abstract
void
setOption(int optID, Object val)
Set the nominated socket option.
Parameters
optID
| the socket option to set |
val
| the option value |
Protected Methods
protected
abstract
void
bind(int port, InetAddress addr)
Bind the datagram socket to the nominated localhost/port. Sockets must be
bound prior to attempting to send or receive data.
Parameters
port
| the port on the localhost to bind |
addr
| the address on the multihomed localhost to bind |
Throws
SocketException
| if an error occurred during bind, such as if the port was
already bound
|
protected
abstract
void
close()
Close the socket.
protected
void
connect(InetAddress inetAddr, int port)
Connect the socket to the specified remote address and port.
Parameters
inetAddr
| the remote address |
port
| the remote port |
Throws
SocketException
| possibly thrown, if the datagram socket cannot be
connected to the specified remote address and port
|
protected
abstract
void
create()
This method allocates the socket descriptor in the underlying operating
system.
protected
void
disconnect()
Disconnect the socket from the remote address and port.
protected
FileDescriptor
getFileDescriptor()
Answer the FileDescriptor, which will be invalid if the socket is closed
or not bound.
Returns
- FileDescriptor the socket file descriptor
protected
int
getLocalPort()
Answer the local port. If the socket was bound to any available port, as
flagged by a
localPort
value of -1, query the IP stack.
Returns
- int the local port to which the socket is bound.
protected
abstract
byte
getTTL()
This method is deprecated.
Replaced by getTimeToLive()
Answer the time-to-live (TTL) for multicast packets sent on this socket.
protected
abstract
int
getTimeToLive()
Answer the time-to-live (TTL) for multicast packets sent on this socket.
protected
abstract
void
join(InetAddress addr)
Add this socket to the multicast group. A socket must join a group before
data may be received. A socket may be a member of multiple groups but may
join any group once.
Parameters
addr
| the multicast group to be joined |
Add this socket to the multicast group. A socket must join a group before
data may be received. A socket may be a member of multiple groups but may
join any group once.
Parameters
addr
| the multicast group to be joined |
netInterface
| the network interface on which the addresses should be dropped |
protected
abstract
void
leave(InetAddress addr)
Remove the socket from the multicast group.
Parameters
addr
| the multicast group to be left |
Remove the socket from the multicast group.
Parameters
addr
| the multicast group to be left |
netInterface
| the network interface on which the addresses should be dropped |
protected
abstract
int
peek(InetAddress sender)
Peek at the incoming packet to this socket and answer the sender's
address into
sender
. The method will block until a packet
is received or timeout expires and returns the sender's port.
protected
abstract
int
peekData(DatagramPacket pack)
Receive data into the supplied datagram packet by peeking. The data is
not removed and will be received by another peekData() or receive() call.
This call will block until either data is received or, if a timeout is
set, the timeout expires.
Parameters
pack
| the DatagramPacket used to store the data |
Returns
- the port the packet was received from
protected
abstract
void
receive(DatagramPacket pack)
Receive data into the supplied datagram packet. This call will block
until either data is received or, if a timeout is set, the timeout
expires. If the timeout expires, the InterruptedIOException is thrown.
protected
abstract
void
send(DatagramPacket pack)
Sends the supplied datagram packet. The packet contains the destination
host & port.
Parameters
pack
| DatagramPacket to send |
protected
abstract
void
setTTL(byte ttl)
This method is deprecated.
Replaced by setTimeToLive(int)
Set the time-to-live (TTL) for multicast packets sent on this socket.
Parameters
ttl
| the time-to-live, 0 < ttl <= 255 |
protected
abstract
void
setTimeToLive(int ttl)
Set the time-to-live (TTL) for multicast packets sent on this socket.
Parameters
ttl
| the time-to-live, 0 < ttl <= 255 |