Client/Server Socket Application - Preventing Client from quitting on server crash

Problem

  • Linux Client/Server Socket Application: Preventing Client from quitting on server crash

Hi,
I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64.

I am having problem trying to implement a scenario where the client should keep running even when the server crashes(because of any reason).

By default, when server closes because of error or when killed by closing the window, the client also quits. I have to somehow handle this situation and make sure the client keeps on running and restarts under this scenario.

I think I need to do handle some unix signals in my client application, I am not sure which ones and how? Can anyone suggest how to go about doing this.

Thanks for suggestions in advance.

Regards
Varun

It may be getting SIGPIPE when trying to write to a closed socket. To handle signals, see man sigaction. On the other hand your application may just be deciding to throw in the towel recv() returns <= 0.

I don't think this is possible.

Not to keep the client socket waiting for "nothing", that's totally possible, of course. If you are learning network programming, you may know a few about TCP/IP protocol stack.

If your client/server application communicate using UDP as transport protocol, excuse me then, it's possible. But if your application communicates using TCP as transport protocol, you're doing nothing keeping the client waiting for data that isn't going to arrive.

TCP uses sequence and acknowledgement numbers, on a server "crash" the application will need to be restarted. at this point, the server will start NEW connections, and forget about the previous ones.

The client application will be sending ack's or data to a connection that is no longer available, and the server will ignore the client. so, you are using UDP, right?