| Article: |
Networking and the BSD Sockets API | |
| Subject: | Address in use | |
| Date: | 2002-12-28 20:29:13 | |
| From: | johnts | |
| Great article, as usual. One thing I noticed, not really having to do with the code. When I run the server (and testing the client), I use Ctrl-C to quit the server. If I try to run the server again I get an error: "bind: Address already in use". Looks like the socket isn't being released right away. If I wait a bit, it will work again. I'm sure it's some TCP protocol issue, but thought I'd mention it. | ||
Showing messages 1 through 2 of 2.
-
Address in use
2002-12-28 22:24:50 jasontm [View]
-
Address in use
2002-12-29 17:44:43 johnts [View]
Got it to work, using code from Beej's Guide page mentioned in another post - there was the exact description of the problem too. I added:
int yes=1;
if (setsockopt(listenfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) < 0) {
perror( "setsockopt" );
exit(1);
}
and I can start the server application right after stopping it without an error.



use the mighty Google to find out more.. i'm too tired to launch into a tutorial. :P
good luck..