I am having an application which established a socket connection on a port number 5005 with another device(hardware device with a web server).
Now if my hardware de
Given that you're talking to a web server, I'll assume you're using TCP sockets.
To answer:
Sockets don't become invalid due to a disconnect; they simply go into a disconnected state. It's still safe to call socket operations on them.
You don't get any special messages when the disconnect occurs. If you call recv() in a blocking fashion, it will return when disconnected, and the number of bytes returned from the call won't match the number of bytes you asked for.
There isn't really an answer to this - it's how the socket API was implemented originally, and we're stuck with that implementation as everyone implements Berkley Sockets.