🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #724

Re: 'could not bind socket' error

#724
From: Remy Lebeau (TeamB)
Date: Wed, 21 Nov 2007 00:10
45 lines
2862 bytes
"Dennis Jones" <nospam@nospam.com> wrote in message 
news:47436c88$1@newsgroups.borland.com...

> But that's just it...I didn't!

Like I said, you *or something else on the machine* had to have done it. 
"Address and port are already in use" does not occur if the IP/Port was not 
previously bound to a socket.

> Yes, I am aware of that.  That is actually the reason I mentioned
> that it was the first time I had run the app in over a day -- because
> that would have been more than enough time for the OS to close
> the socket.

Another socket on the machine is using the same IP/Port that you want to 
use.  Either your previous server instance is still active, or another 
program has created its own socket, or a local firewall is blocking the 
binding.  Those are the only possibilities for that particular error to 
occur.

> So you keep saying.  And in fact, that is exactly the reason I checked 
> netstat in the first place.  I assumed netstat would be accurate (but
> maybe it's not).

It is.

> The fact that netstat does not show the port in use is the only reason I 
> asked the question to begin with.  If netstat had listed
> the port, it would have been obvious that there was a problem
> with closing the socket and I wouldn't have bothered posting here!

Are you sure you are looking for the port that you are actually using in 
your code?  What exactly are you setting for the IP/Port of your server? 
Please show your actual code.

> So, being certain that netstat does not show the port in use, and
> being certain that the app is not already running, what would you
> suggest I do the next time this occurs?

The error is not possible under those conditions.  Bound sockets can't hide 
from netstat.  They are either bound or they are not.


Gambit 
Technical Details
Message-ID: <474377e3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <47431d9f$1@newsgroups.borland.com> <474342ce@newsgroups.borland.com> <47434723$1@newsgroups.borland.com> <474358f3@newsgroups.borland.com> <47436c88$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,128d041863311899
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <47431d9f$1@newsgroups.borland.com> <474342ce@newsgroups.borland.com> <47434723$1@newsgroups.borland.com> <474358f3@newsgroups.borland.com> <47436c88$1@newsgroups.borland.com>
Subject: Re: 'could not bind socket' error
Date: Tue, 20 Nov 2007 16:10:55 -0800
Lines: 47
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 207.178.157.90
Message-ID: <474377e3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195603939 207.178.157.90 (20 Nov 2007 16:12:19 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail