1755152 Members
4769 Online
108830 Solutions
New Discussion юеВ

Socket problem

 
SOLVED
Go to solution
Osa Jousou
Occasional Advisor

Socket problem

We have a c program that opens and connects a socket to one of our vendors for the purpose of exchanging information. We disconnect the socket after midnight using ndd disconnect by address. The problem we're having is, when we start the process in the morning, the socket status starts in "Established" mode and since their are no files to exchange with the vendor the socket goes into "Time_Wait" status which causes our program to fail and socket to disconnect. My workaround, was to send a single packet at startup across the connection. That makes the socket stay open even if no data was exchanged for a couple of hours. I would like to know why it only works when I send that packet. If someone has a solution or suggestion to how I can get it to start without the initial packet, please send me your thoughts.
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Socket problem

First of all using rather than using ndd to clobber the connections, I would rather see you code a signal handler to shutdown the socket more gracefully.

I suspect that you need to use setsockopt() to set SO_KEEPALIVE.
If it ain't broke, I can fix that.
Dagmar Boelen
Frequent Advisor

Re: Socket problem

You can configure you time-wait interval

ndd -get /dev/tcp tcp_time_wait_interval

-> this shows your current setting.

To change it
ndd -set /dev/tcp/tcp_time_wait_interval (in seconds)

to make it permanent
change the setting in
/etc/rc.config.d/nddconf

Caesar_3
Esteemed Contributor

Re: Socket problem

Hello!

If it's your code i don't think that it's
a good thing that your program not control
the close of connection, you should check the
source and made changes and the work with
signals will be fine for this.

Caesar