Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


June 01, 2000

Bind Basics


RSS
View this exclusive article with VIP access -- click here to join |
See More Security Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

In Windows NT, the system typically assigns network-based TCP/IP services to a well-known port, in accordance with Request for Comments (RFC) 1700. POP3 servers, the topic of this continuing series of articles, run on TCP port 110. The first step in getting your mail server to answer requests on that port is to bind the socket.

To understand how to bind a TCP socket to a port, you need to look at the arguments for the bind() function. One of these arguments (the second) is a pointer to a sockaddr structure. For IP applications, that pointer is typically a sockaddr_in structure that contains the numeric IP address and port that you want to bind to locally. If you can't easily identify what interfaces are available, you can simply bind to all available local interfaces by specifying INADDR_ANY as the address.

One security risk that you need to be aware of is that users can bind two sockets to the same port using a socket option known as SO_REUSEADDR. In other words, two different applications can answer connections on the same port. So, in the case of a POP3 server, one application might be delivering mail, while another is stealing passwords. Working with NT 4.0 and earlier requires a lot of Registry reads to determine which IP addresses are available. As a result, many programmers simply specify INADDR_ANY to get all the interfaces. Under Windows 2000, you can have new interfaces popping up and down on the fly. Unless you’re prepared to write code to detect these changes, your service might not behave properly if you don’t bind to all the interfaces.

You're probably thinking, "Why not just specify INADDR_ANY all the time and avoid these problems?" Here's the catch: If someone does bind to a specific IP address, the OS prefers the specifically bound socket to one that binds to all available interfaces. To handle this problem, Microsoft implemented the SO_EXCLUSIVEADDRUSE socket option in NT 4.0 Service Pack 4 (SP4) and Win2K. . . .

Reader Comments
This is a nice article and really gives an insight about how process get bind to a port.

I am really sorry I am using this feedback form for discussing my problem.

But I would like to ask one thing. I am facing a JVM bind error in my application occasionally.

To give an insight of the application, I have a Java/EJB application. Many EJB services are running on different ports.

the problem here is, sometime once the site is up. some ports remain occupied once the process cummunicating with them ends. and then this lead to a server socket connection refused error and lead subsytem to the shutdown mode.

then i have to restart the server by killing those process and free the port to let the site working properly

I am not sure what is causing the ports to be occupied once the site gets a clean start.

To give an example, what i am saying, Some time say a process running on port 2145 will be occupied by the process running on port 1433 (SQL SERVER defaul port). It is just a one case of my problem.

Please help me in this.

I would be very thankful to you :)

Karan July 08, 2004


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

New Microsoft/Yahoo! Deal? No

On Sunday, the Times of London reported that Microsoft had renewed talks with failing Internet giant Yahoo! and would manage its search engine for 10 years, while Yahoo! would retain control of its email, messaging, and content services. This report ...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...


Security Whitepapers The Impact of Messaging and Web Threats

Why SaaS is the Right Solution for Log Management

Protecting (You and) Your Data with Exchange Server 2007

Related Events How IE7 & The New Extended Validation SSL Certificates Impact Your Site

Top 10 Email Security Challenges and Solutions

Introduction to Identity Lifecycle Manager "2"

Check out our list of Free Email Newsletters!

Security eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

Related Security Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing