Differences Between Listening Socket Reuse Behavior in Windows 2000 and Windows NT 4.0 (307175)
The information in this article applies to:
- Microsoft Windows 2000 Server
- Microsoft Windows 2000 Advanced Server
- Microsoft Windows 2000 Professional
- Microsoft Windows NT Server 4.0
- Microsoft Windows NT Workstation 4.0
- Microsoft .NET Framework 1.0
This article was previously published under Q307175 SUMMARY
This article describes the differences between the listening socket reuse behavior in Windows 2000 and in Windows NT 4.0.
MORE INFORMATION
After the server accepts a connection, the listening socket may be closed. When a second instance of the server is started, the behavior varies depending on the operating system.
In Windows NT 4.0, if you call the bind() function on the same listening port, the action is unsuccessful, and you receive an "error 10048" message. To prevent this error message, use setsockopt() with the SO_REUSADDR option on a listener socket after the previous session is closed.
In Windows 2000, the bind() function is returned successfully. If you set SO_REUSADDR to False, the bind() function is still returned successfully.
The behavior in Windows 2000 is a marginal improvement to the listening socket because Windows 2000 allows you to bind to a listening port when the previous session is fully closed.
Closed listening socket sessions on the port may still be listed when you run Netstat.exe. This behavior occurs because of the difference between Transport Driver Interface (TDI) and the Winsock interface. Netstat.exe does not report on sockets, it reports on opened TDI address objects. The TDI address object remains open as long as it lists one connection that is accepted on the address. When you run Netstat.exe, the listening socket sessions are displayed because the listen() function was successfully called at least one time on that object. After a listening session is closed, no listening sessions are currently outstanding and no additional connections are accepted on this address object. However, Netstat.exe cannot determine whether this state is temporary or permanent. NOTE: If a listening socket is not closed, if you call the bind() function on the same port, you receive an "error 10048" message in both Windows NT 4.0 and Windows 2000 unless you use SO_REUSADDR. If you use SO_REUSADDR to bind multiple servers to the same port at the same time, only one random listening socket accepts a connection request.
Modification Type: | Major | Last Reviewed: | 12/23/2003 |
---|
Keywords: | kbAPI kbinfo kbnetwork kbreadme kbWinsock KB307175 |
---|
|