Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 307175 - Last Review: March 1, 2007 - Revision: 4.3
Differences Between Listening Socket Reuse Behavior in Windows 2000 and Windows NT 4.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.
APPLIES TO
- Microsoft Windows 2000 Server
- Microsoft Windows 2000 Advanced Server
- Microsoft Windows 2000 Professional Edition
- Microsoft Windows NT Server 4.0 Standard Edition
- Microsoft Windows NT Workstation 4.0 Developer Edition
- Microsoft .NET Framework 1.0
| kbinfo kbwinsock kbapi kbnetwork kbreadme KB307175 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please