Java Reference
In-Depth Information
only send datagrams, because a datagram source address is always a unicast address
(see Section 4.3).
remoteAddr
Remote address
remotePort
Remote port
void
disconnect
()
Removes the remote address and port specification of the socket (see
connect()
).
void
receive
(
DatagramPacket
packet
)
Places data from the next received message into the given
DatagramPacket
.
packet
Receptacle for received information, including source
address and port as well as message data. (See the
DatagramPacket
reference for details of semantics.)
void
send
(
DatagramPacket
packet
)
Sends a datagram from this socket.
packet
Specifies the data to send and the destination address and
port. If
packet
does not specify a destination address, the
DatagramSocket
must be “connected” to a remote address
and port (see
connect()
).
Accessors/Mutators
InetAddress
getInetAddress
()
int
getPort
()
Returns the remote socket address/port.
InetAddress
getLocalAddress
()
int
getLocalPort
()
Returns the local socket address/port.
int
getReceiveBufferSize
()
int
getSendBufferSize
()
void
setReceiveBufferSize
(
int
size
)
void
setSendBufferSize
(
int
size
)
The
DatagramSocket
has limits on the maximum datagram size that can be sent/
received through this socket. The receive limit also determines the amount of message
data that can be queued waiting to be returned via
receive()
. That is, when the amount
of buffered data exceeds the limit, arriving packets are quietly discarded. Setting the
size is only a hint to the underlying implementation. Also, the semantics of the limit
may vary from system to system: it may be a hard limit on some and soft on others.
size
Desired limit on packet and/or queue size (bytes)
Search WWH ::
Custom Search