Networking Forums

Networking Forums > Computer Networking > Linux Networking > Linux (RH8) Socket Timeouts

Reply
Thread Tools Display Modes

Linux (RH8) Socket Timeouts

 
 
Otto Blomqvist
Guest
Posts: n/a

 
      09-17-2004, 04:27 PM
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
 
Reply With Quote
 
 
 
 
=?ISO-8859-15?Q?S=E9bastien?= Cottalorda
Guest
Posts: n/a

 
      09-20-2004, 01:37 PM
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 ]
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Linux and embedded Linux provides RAW socket? GS Linux Networking 3 04-14-2007 05:26 AM
Socket Timeouts Dan N Linux Networking 7 09-19-2005 06:31 PM
Disabling a Linux TCP/IP Socket B.Ravi Kumar Linux Networking 1 06-10-2004 07:01 PM
Linux Socket Problem? LaBird Linux Networking 2 02-23-2004 07:04 AM
linux socket programming sank Linux Networking 2 01-02-2004 05:36 PM



1 2 3 4 5 6 7 8 9 10 11