Otto Blomqvist wrote:
> Hello !
>
> I have an application that works just fine, BUT after stopping the app
> it takes about 30 seconds before I can connect again. There are two
> deamons running on the same box and they communicate using TCP/IP
> sockets. Here is some of my code
>
> gw030_sockfd = socket(AF_INET, SOCK_STREAM, 0);
> bind(gw030_sockfd, (struct sockaddr *) &gw030_address, gw030_len);
> //gw030_address points to 127.0.0.1
>
> listen(gw030_sockfd, 5);
> client_sockfd = accept(gw030_sockfd, (struct sockaddr *)
> &client_address, &client_len);
>
> My problem is that after stopping both deamons it takes about 30-40
> seconds before I can start them again. Upon trying the second daemon
> (the client) cannot establish a TCP/IP connection using 'connect(..)'
> to the other deamon. Other than that it works great, so I am
> suspecting I fail to close or shutdown the socket properly. Right now
> I'm simply doign a close(gw030_sockfd);
>
> Any ideas ?
>
> /Otto Blomqvist
Try to use getsockopt with SO_REUSEADDR on the server side.
If you want linux to close faster a socket see:
http://howtos.linux.com/guides/solrh...ap6sec75.shtml
Regards.
Sebastien
--
[ retirer NOSPAM pour répondre directement
remove NOSPAM to reply directly ]