Socket

  • Thread starter Thread starter Wally
  • Start date Start date
W

Wally

Hallo
Is there anybody able to tell me if and how to restore a lost socket
communication?
I try to explain.
Computer A and computer B are net connected and they estabilished a socket
connection. A (which acts as a server) is waiting for data from B and,
while waiting, it sends a "ping" character to B, in order to verify is the
connection is active.
Desconnecting the net cable, the "ping" character sending generates an
exception, as you can rightly presume that to connetion is no more active.
So far so good.
The problem is that re-connecting the net cable, the "ping" character
sending generates the same exception, just as if the lost communication
couldn't be recuperated unless you do a new call. Any idea or suggestion?

Thanks anyhow.

VV
 
Hi,


Take a look at this article. It uses a ping to see if the
computer is connected to the network.

http://msdn.microsoft.com/library/d...ry/en-us/dndotnet/html/northwindunplugged.asp

Ken
-----------------


Hallo
Is there anybody able to tell me if and how to restore a lost socket
communication?
I try to explain.
Computer A and computer B are net connected and they estabilished a socket
connection. A (which acts as a server) is waiting for data from B and,
while waiting, it sends a "ping" character to B, in order to verify is the
connection is active.
Desconnecting the net cable, the "ping" character sending generates an
exception, as you can rightly presume that to connetion is no more active.
So far so good.
The problem is that re-connecting the net cable, the "ping" character
sending generates the same exception, just as if the lost communication
couldn't be recuperated unless you do a new call. Any idea or suggestion?

Thanks anyhow.

VV
 
Thank you Ken, but this article suggest to use a Ping method of a Web
service. I'm not using Web services.
How can I ping a computer on my LAN without using web services?

VV
 
Hallo
Is there anybody able to tell me if and how to restore a lost socket
communication?
I try to explain.
Computer A and computer B are net connected and they estabilished a socket
connection. A (which acts as a server) is waiting for data from B and,
while waiting, it sends a "ping" character to B, in order to verify is the
connection is active.
Desconnecting the net cable, the "ping" character sending generates an
exception, as you can rightly presume that to connetion is no more active.
So far so good.
The problem is that re-connecting the net cable, the "ping" character
sending generates the same exception, just as if the lost communication
couldn't be recuperated unless you do a new call. Any idea or suggestion?

Thanks anyhow.

VV

Once the connection is lost, you need to open a new connection.
 
i know how to do this. i used to sent pong to server when server pinged
me. i used to do irc chat similar to mirc. first u ( as server) must
send command "PING" to client every 30 second (it is up to u to send
ping more than 30 seconds). Now on client side when client recived
PING's command from server ....the client automatically sent command
"PONG" to server. Now if server don't received command "PONG" from
client, then server can disconnected to client or close socket for
client. this is how it works. u will have to write code for urself.
regards
 
know how to do this. i used to sent pong to server when server pinged
me. i used to do irc chat similar to mirc. first u ( as server) must
send command "PING" to client every 30 second (it is up to u to send
ping more than 30 seconds). Now on client side when client recived
PING's command from server ....the client automatically sent command
"PONG" to server. Now if server don't received command "PONG" from
client, then server can disconnected to client or close socket for
client. this is how it works. u will have to write code for urself.
regards
 
1 Dim bConnectionLost as Boolean
2 Dim bMsg(10000) As Byte
3 Dim sPingChar as String=Chr(0)
4 Do
5 Try
6 bMsg = System.Text.Encoding.UTF8.GetBytes(sPingChar.ToCharArray)
7 pobjSocket.Send(bMsg, bMsg.Length, SocketFlags.None)
8 bConnectionLost=False
9 Catch ex As Exception
10 bConnectionLost = True
11 End Try
12 Loop Until Not bConnectionLost
13 ...

- When network cable is connected bConnectionLost is set to False, no
exceptions and the flow works fine.
- If I disconnext cable flow loops into DO / LOOP UNTIL of course.
- When I reconnect cable, bConnectionLost doesn't change to False again so
flow doesn't exit from DO / LOOP UNTIL
 
It depends on what protocol you are using. If it is TCP, then you are out of
luck. When you disconnect, TCP detects that the connection was broken. The
socket will go into a disconnected state, and you will have to reconnect
again.

--
feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------
 
Back
Top