Java Reference
In-Depth Information
than 1023. For a Socket instance returned by accept() , the local address is the destination
address from the initial handshake message from the client, the local port is the local port of
the ServerSocket , and the foreign address/port is the local address/port of the client. For a
DatagramSocket , the local address and/or port may be specified to the constructor. Otherwise
the local address is the wildcard address, and the local port is a randomly selected, unused
port number greater than 1023. The foreign address and port are initially both wildcards, and
remain that way unless the connect() method is invoked to specify particular values.
5.6
Exercises
1. The TCP protocol is designed so that simultaneous connection attempts will succeed.
That is, if an application using port P and Internet address W.X.Y.Z attempts to connect
to address A.B.C.D, port Q, at the same time as an application using the same address
and port tries to connect to W.X.Y.Z, port P, they will end up connected to each other.
Can this be made to happen when the programs use the sockets API?
2. The first example of “buffer deadlock” in this chapter involves the programs on both
ends of a connection trying to send large messages. However, this is not necessary for
deadlock. How could the TCPEchoClient from Chapter 2 be made to deadlock when it
connects to the TCPEchoServer from that chapter?
Search WWH ::




Custom Search