General
cancel
Showing results for 
Search instead for 
Did you mean: 

how to capture the signal of interrupt connecting Socket?

doantien_1
Occasional Visitor

how to capture the signal of interrupt connecting Socket?

Hi all!!!
I have writen client socket by C language connect to socket server order to tranfer file between them (Socket client running on HP-UX). But I have got a problem, socket server somtime disconnect from session but I don't capture the signal of interrupt session to resume transfer file session when client connect again.
Plz help me
4 REPLIES
Torsten.
Acclaimed Contributor

Re: how to capture the signal of interrupt connecting Socket?

Based on the information given I can only advise to check your signal handlers.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
doantien_1
Occasional Visitor

Re: how to capture the signal of interrupt connecting Socket?

Thanks Torsten!!!
Nomally, Client and Server socket transfer data each other. When have a problem, ex: Socket Server had been power suddenly shutdown or Socket server hang...I must fransfer file from first. I want write pointer of file (I write a C program read a file and the file is read fransfer from client to server) to other file before client socket closed. But I can't do it, plz help me.

rick jones
Honored Contributor

Re: how to capture the signal of interrupt connecting Socket?

Strictly speaking you have no way of knowing how far the server got in terms of reading data from its socket before the server went down without the server application telling you in some way.

That could take the form of periodic "I have gotten as far as N" messages back the other way on the connection.

Perhaps it could take the form of the client saying "how large is this file" and the server saying it is N bytes in size and the client deciding to start transferring from N. That would probably have to be coupled with the client only using that mechanism on a reconnect after disconnect and not on an initial connect.
there is no rest for the wicked yet the virtuous have no pillows
Laurent Menase
Honored Contributor

Re: how to capture the signal of interrupt connecting Socket?

1) a signal is received only if a write() is done on a socket which is already reset.
2) The connection is reset when:
- there is unsent data, and retransmissions failed. retransmission will last for tcp_ip_abort_interval (ndd tunable 10 min/default). Retransmission may stop also if peer system reset the connection - after a reboot for instance.
3) disconnection on read() side is detected if we receive a reset. If connectivity is completely lost, only keepalive option may help to detect the problem.
by default keepalive is not set, and keepalive interval is 2 hours.

- so you may reduce the interval to detect it sooner - don't set abort interval to a too low value.


Else only your protocol can help you on identifying sooner connectivity is lost and where.
for instance, send an ack every 128k with a timeout, So you know where to start over.