java.lang.Object | |
↳ | java.net.DatagramSocketImpl |
The abstract superclass for datagram and multicast socket implementations.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.net.SocketOptions
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
fd | File descriptor that is used to address this socket. | ||||||||||
localPort | The number of the local port to which this socket is bound. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs an unbound datagram socket implementation.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Binds the datagram socket to the given localhost/port.
| |||||||||||
Closes this socket.
| |||||||||||
Connects this socket to the specified remote address and port.
| |||||||||||
This method allocates the socket descriptor in the underlying operating
system.
| |||||||||||
Disconnects this socket from the remote host.
| |||||||||||
Gets the
FileDescriptor of this datagram socket, which is invalid
if the socket is closed or not bound. | |||||||||||
Gets the local port of this socket.
| |||||||||||
This method is deprecated.
Replaced by
getTimeToLive() | |||||||||||
Gets the time-to-live (TTL) for multicast packets sent on this socket.
| |||||||||||
Adds this socket to the multicast group
addr . | |||||||||||
Adds this socket to the multicast group
addr . | |||||||||||
Removes this socket from the multicast group
addr . | |||||||||||
Removes this socket from the multicast group
addr . | |||||||||||
Peeks at the incoming packet to this socket and returns the address of
the
sender . | |||||||||||
Receives data into the supplied datagram packet by peeking.
| |||||||||||
Receives data and stores it in the supplied datagram packet
pack . | |||||||||||
Sends the given datagram packet
pack . | |||||||||||
This method is deprecated.
Replaced by
setTimeToLive(int) | |||||||||||
Sets the time-to-live (TTL) option for multicast packets sent on this
socket.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.net.SocketOptions
|
The number of the local port to which this socket is bound.
Constructs an unbound datagram socket implementation.
Binds the datagram socket to the given localhost/port. Sockets must be bound prior to attempting to send or receive data.
port | the port on the localhost to bind. |
---|---|
addr | the address on the multihomed localhost to bind. |
SocketException | if an error occurs while binding, for example, if the port has been already bound. |
---|
Connects this socket to the specified remote address and port.
inetAddr | the address of the target host which has to be connected. |
---|---|
port | the port on the target host which has to be connected. |
SocketException | if the datagram socket cannot be connected to the specified remote address and port. |
---|
This method allocates the socket descriptor in the underlying operating system.
SocketException | if an error occurs while creating the socket. |
---|
Gets the FileDescriptor
of this datagram socket, which is invalid
if the socket is closed or not bound.
Gets the local port of this socket.
This method is deprecated.
Replaced by getTimeToLive()
Gets the time-to-live (TTL) for multicast packets sent on this socket.
IOException | if an error occurs while getting the time-to-live option value. |
---|
Gets the time-to-live (TTL) for multicast packets sent on this socket. The TTL option defines how many routers a packet may be pass before it is discarded.
IOException | if an error occurs while getting the time-to-live option value. |
---|
Adds this socket to the multicast group addr
. A socket must join
a group before being able to receive data. Further, a socket may be a
member of multiple groups but may join any group only once.
addr | the multicast group to which this socket has to be joined. |
---|
IOException | if an error occurs while joining the specified multicast group. |
---|
Adds this socket to the multicast group addr
. A socket must join
a group before being able to receive data. Further, a socket may be a
member of multiple groups but may join any group only once.
addr | the multicast group to which this socket has to be joined. |
---|---|
netInterface | the local network interface which will receive the multicast datagram packets. |
IOException | if an error occurs while joining the specified multicast group. |
---|
Removes this socket from the multicast group addr
.
addr | the multicast group to be left. |
---|
IOException | if an error occurs while leaving the group or no multicast address was assigned. |
---|
Removes this socket from the multicast group addr
.
addr | the multicast group to be left. |
---|---|
netInterface | the local network interface on which this socket has to be removed. |
IOException | if an error occurs while leaving the group. |
---|
Peeks at the incoming packet to this socket and returns the address of
the sender
. The method will block until a packet is received or
timeout expires.
sender | the origin address of a packet. |
---|
sender
as an integer value.IOException | if an error or a timeout occurs while reading the address. |
---|
Receives data into the supplied datagram packet by peeking. The data is
not removed from socket buffer and can be received again by another
peekData()
or receive()
call. This call blocks until
either data has been received or, if a timeout is set, the timeout has
been expired.
pack | the datagram packet used to store the data. |
---|
IOException | if an error occurs while peeking at the data. |
---|
Receives data and stores it in the supplied datagram packet pack
.
This call will block until either data has been received or, if a timeout
is set, the timeout has expired. If the timeout expires an InterruptedIOException
is thrown.
pack | the datagram packet container to fill in the received data. |
---|
IOException | if an error or timeout occurs while receiving data. |
---|
Sends the given datagram packet pack
. The packet contains the
data and the address and port information of the target host as well.
pack | the datagram packet to be sent. |
---|
IOException | if an error occurs while sending the packet. |
---|
This method is deprecated.
Replaced by setTimeToLive(int)
Sets the time-to-live (TTL) option for multicast packets sent on this socket.
ttl | the time-to-live option value. Valid values are 0 < ttl <= 255. |
---|
IOException | if an error occurs while setting the option. |
---|
Sets the time-to-live (TTL) option for multicast packets sent on this socket.
ttl | the time-to-live option value. Valid values are 0 < ttl <= 255. |
---|
IOException | if an error occurs while setting the option. |
---|