Identifying Server graceful shutdown


 
Thread Tools Search this Thread
Special Forums IP Networking Identifying Server graceful shutdown
# 1  
Old 01-27-2011
Identifying Server graceful shutdown

Hi
I have written a Client server Application .The client will receive messages from Server and pass it to some library for processing .I also want to notify server close the socket connection gracefully.

Roughly my code is some kind of

void getMsg()
{
while(recv(....)>0)
{
cout<<"Process Message";
}
cout<<"Server Disconnected";
}


The problem with the above code is of server get crash because of some reason recv function is returning 0 immediately .But There is no way to identify from client side whether server is close gracefully or because of some error .

Is there any way to identify them .
# 2  
Old 01-27-2011
If it really returned zero, then, according to recv's manpage the shutdown was orderly -- you were informed the socket was going away. You didn't have to wait several minutes before timing out. It's not disorderly, simply unexpected, and your code is the only that might realize that, TCP/IP wouldn't know.
# 3  
Old 01-28-2011
Thanks for your reply.
But I need to write log based on if server is shutdown gracefully or because of some Crash.
# 4  
Old 01-28-2011
There's only so much you can learn from a lack of information.

If you weren't expecting even a graceful close, you can probably mark that down to either a server bug, server crash, or someone killing that program. I'd have expected an actual error return from a network problem. And if it breaks gracelessly that could be either a network problem or someone pulling the plug(data, power, whatever -- yours or theirs!). Experiment with it a bit, see what results you get from different kinds of failures. There might be nothing for it but to see if it's possible to recontact the server after the socket close to tell the difference between some failures.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Identifying the vio server names

Hi My vio client is getting its virtual Ethernet services from dual vio servers. What command if I execute on the vio client will get me the names of the vio servers ? (2 Replies)
Discussion started by: samsungsamsung
2 Replies

2. AIX

Server Shutdown

Hi, is it possible to find out ip address of user who has shutdown or rebooted the server , I have used the command errpt -a , in that it is showing server rebooted but it is not showing ip address who has shutdown the serve, even I have used command last reboot. Please suggest. Regards, ... (3 Replies)
Discussion started by: manoj.solaris
3 Replies

3. Solaris

Solaris 10 container graceful shutdown?

Hi, I've got a UPS connected to my Solaris 10 machine and I'm planning to run containers/zones on there. At the moment if the UPS agent sends the signal to the solaris machine to shutdown, all the apps shutdown gracefully and then the host goes down. If I setup containers for the apps, does... (9 Replies)
Discussion started by: fastexit
9 Replies

4. UNIX for Advanced & Expert Users

Shutdown the Linux server if no one is using the server

Hi All, I want to shutdown the server if no one is actualy using it. Its a linux server. I thought of sending a msg on users terminal for those who all are logged in and expecting a input from them. If they will reply system should not get shutdown else it should not. Can any one... (2 Replies)
Discussion started by: Sadhana
2 Replies

5. Solaris

Startup and shutdown a server

Are rc scripts executed serially or all at the same time. Is there a way to see this happen? A log file or the syslogd? This is Solaris 10. (2 Replies)
Discussion started by: djehresmann
2 Replies

6. Solaris

Server Shutdown Problem

I have a sparc T1 server (I know its old) running Solaris 8, which we use for testing. It has been very slow in response- prompt takes couple of minutes to come up, so I decided to reboot the server but I can reboot it, it is giving following errors when I try to shutdown it down. root@deva:/#... (3 Replies)
Discussion started by: Tirmazi
3 Replies

7. AIX

server is getting shutdown

Hi Guys, Please help in this...when we start HACMP services ..server is getting shutdon. Error mesg from cluster.log. Apr 14 08:43:27 bascop17 snmpd: NOTICE: SMUX trap: (0 0) (127.0.0.1+46302+1) Apr 14 08:43:33 bascop17 topsvcs: (Recorded using libct_ffdc.a cv 2):::Error ID:... (1 Reply)
Discussion started by: b_manu78
1 Replies

8. Solaris

graceful shutdown during poweroutage

I'm thinking of buying a UPS, does Solaris have any software builting to detect when a system goes into UPS dependency, or would the best best to use some software provided by APC or some other UPS vendor...? (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

9. UNIX for Advanced & Expert Users

shutdown a unix server

Hi, how to shutdown a unix machine ? We are on SunOS server15.8 Generic_108528-24 sun4u sparc SUNW,Ultra-Enterprise Many thanks. (2 Replies)
Discussion started by: big123456
2 Replies

10. UNIX for Dummies Questions & Answers

Server shutdown Troubleshooting

SCO Unixware 7.1.1 Hi friends, At 11:30pm last night mymain Unix Server hung or rebooted (Unaware which one), and was bot available for 10 minutes. Is there a log file somewhere which will tell me what happened ? I have looked ad /var/adm/syslog, but cannot make head nor tail of it. ... (1 Reply)
Discussion started by: sureshy
1 Replies
Login or Register to Ask a Question