TCP IP Illustrated

On our host sun we can start five different servers

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: art different servers at the same port, each with a different local IP address. Normally, however, the system must be told by the application that it is OK to reuse the same port number. With the sockets API the SO_REUSEADDR socket option must be specified. This is done by our sock program by specifying the -A option. On our host sun we can start five different servers on the same UDP port (8888): sun % sock -u -s 140.252.1.29 8888 sun % sock -u -s -A 140.252.13.33 8888 sun % sock -u -s -A 127.0.0.1 8888 for SLIP link for Ethernet for loopback interface file:///D|/Documents%20and%20Settings/bigini/Doc...omenet2run/tcpip/tcp-ip-illustrated/udp_user.htm (25 of 29) [12/09/2001 14.46.58] Chapter 11. UDP: User Datagram Protocol sun % sock -u -s -A 140.252.13.63 8888 sun % sock -u -s -A 8888 everything else (wildcard IP address) for Ethernet broadcasts All except the first of the servers must be started with the -A flag, telling the system that it's OK to reuse the same port number. The netstat output shows the five servers: Proto Recv-Q Send-Q udp udp udp udp udp 0 0 0 0 0 0 0 0 0 0 Foreign Address *.8888 *.* 140.252.13.63.8888 *.* 127.0.0.1.8888 *.* 140.252.13.33.8888 *.* 140.252.1.29.8888 *.* Local Address (state) In this scenario, the only datagrams that will go to the server with the wildcarded local IP address are those destined to 140.252.1.255, because the other four servers cover all other possibilities. There is a priority implied when an end point with a wildcard address exists. An end point with a specific IP address that matches the destination IP address is always chosen over a wildcard. The wildcard end point is used only when a specific match is not found. Restricting Foreign IP Address In all the netstat output that we showed earlier, the foreign IP address and foreign port number are shown as *.* meaning the end point will accept an incoming UDP datagram from any IP address and any port number. Most implementations allow a UDP end point to restrict the foreign address. This means the end point will onl...
View Full Document

Ask a homework question - tutors are online