sockets - The meaning of Java's DatagramChannel.write() -
i found code using datagramchannel.write()
. code asked host ip , port before connected , allow sending (via datagramchannel.write()
).
being new network programming, seemed odd wouldn't request destination ip/port. why not?
oracle's documentation states
this method may invoked if channel's socket connected, in case sends datagrams directly socket's peer.
what mean "the socket's peer"?
datagramchannel part of java.nio package. take parameter bytebuffer send connected channel. before trying send should connect using inetsocketaddress, takes host ip , port parameter. connect(socketaddress remote) --> connects channel underlying socket. can socket datagramchannel because channel non blocking io used read/write purpose. socket peer's nothing remote machine.
Comments
Post a Comment