473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Socket

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
Jul 21 '05 #1
8 1603
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/de...dunplugged.asp

Ken
-----------------
"Wally" <va****@nospamcambieri.it> wrote in message
news:Z5***********************@news4.tin.it...
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

Jul 21 '05 #2
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
"Ken Tucker [MVP]" <vb***@bellsouth.net> ha scritto nel messaggio
news:eC**************@TK2MSFTNGP09.phx.gbl...
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/de...dunplugged.asp
Ken
-----------------
"Wally" <va****@nospamcambieri.it> wrote in message
news:Z5***********************@news4.tin.it...
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

Jul 21 '05 #3
In article <Z5***********************@news4.tin.it>, Wally wrote:
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.

--
Tom Shelton [MVP]
Jul 21 '05 #4
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

Wally wrote:
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


Jul 21 '05 #5
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

Wally wrote:
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


Jul 21 '05 #6
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.ToCha rArray)
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
"Supra" <su*****@rogers.com> ha scritto nel messaggio
news:bf*****************@news04.bloor.is.net.cable .rogers.com...
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

Wally wrote:
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 socketconnection. 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 theconnection 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

Jul 21 '05 #7
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.
----------------

"Wally" <va****@nospamcambieri.it> wrote in message
news:ZQ***********************@news4.tin.it...
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.ToCha rArray)
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
"Supra" <su*****@rogers.com> ha scritto nel messaggio
news:bf*****************@news04.bloor.is.net.cable .rogers.com...
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

Wally wrote:
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 socketconnection. 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 theconnection 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


Jul 21 '05 #8
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.
----------------

"Wally" <va****@nospamcambieri.it> wrote in message
news:ZQ***********************@news4.tin.it...
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.ToCha rArray)
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
"Supra" <su*****@rogers.com> ha scritto nel messaggio
news:bf*****************@news04.bloor.is.net.cable .rogers.com...
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

Wally wrote:
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 socketconnection. 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 theconnection 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


Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: simon place | last post by:
Spent some very frustrating hours recoding to find a way of closing a server socket, i'd not thought it would be any problem, however, after complete failure and as a last resort, i looked at the...
4
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects...
6
by: roger beniot | last post by:
I have a program that launches multiple threads with a ThreadStart method like the following (using System.Net.Sockets.Socket for UDP packet transfers to a server): ThreadStart pseudo code: ...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
5
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for...
4
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.