2nd attempt of bind fault

Status
Not open for further replies.

DCO_81

Member level 1
Joined
Mar 10, 2005
Messages
39
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Germany, south
Activity points
1,657
Hi,

has anybody ever got a problem like this.

My program waits till it´s connected via ppp with another system. Then it calls a bind after a normal socket is opened. Followed by an listen and accept I can send an receive data. But when I start my program again bind always gives me -1 as return value. I don´t have a cure why this happens...
 

first u create the socket then u fill in the socket address structure n then you bind.So try changing the information u fill into the socket like the port no.there might be a reason tat the port no u want to bind the socket to might be already under use.
 

Also, sometimes the OS is a bit slow in releasing a port.
But hey, I only have experience with sockets in windows ;-).

Does it occur always or only when you start the program again directly after it ends?
And you're sure the program is ended? (or in a multithreaded/multiprocess program something keeps running zombie (you forked and didn't end the child processes when the parent ended?) )

Antharax
 

It´s no multithreaded or multiprocess program. How can I check the OS released the port again?
 

by trying to open it again?
I sometimes have the problem in windows that when i close an application with a listener thread on a certain port that i cannot close and reopen it immediately. After a few seconds (sometimes more) it works again. (but it can be a problem in the application too).
But this might be caused by my application (closing all thread and the socket correctly?)

In windows there might be some other issues too:
(search for reopen in the following document. **broken link removed**)

Antharax
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…