R
Rich Hanbidge [MSFT]
Hi Anderson,
You are running into a problem with TCP itself. TCP will not detect
connection failures when you are receiving data, only when sending.
What you can do though, is use Socket.Select. This will keep you from
freezing the application.
You may be able to perform a Send of size zero, to test the connection, but
I don't know if that will work. You may mess up any reads from the other
end.
Good luck!
Rich
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Anderson Takemitsu Kubota" <[email protected]>
| Subject: How to implement the Socket Timeout when receiving data?
| Date: Mon, 30 Jun 2003 12:24:38 -0300
| Lines: 24
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 200.189.66.138
| Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa09.phx.gbl
microsoft.public.dotnet.framework.compactframework:9493
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi!
|
| I read some posts on this group about this topic and I saw I need to
| implement the close in a timer event.
| Can anybody help me for this? I don't know how to do it.
|
| This is a sample code that I am using:
|
| while (true)
| {
| bytes = cSocket.Receive(buffer, buffer.Length, 0);
| output.Write(this.buffer,0,this.bytes);
| if ( this.bytes <= 0)
| break;
| }
|
| The problem is that if I lost connection in the while block the
| cSocket.Receive doesn't return any value and freezes the application.
|
| Thank you.
|
| Anderson T. Kubota
|
|
|
You are running into a problem with TCP itself. TCP will not detect
connection failures when you are receiving data, only when sending.
What you can do though, is use Socket.Select. This will keep you from
freezing the application.
You may be able to perform a Send of size zero, to test the connection, but
I don't know if that will work. You may mess up any reads from the other
end.
Good luck!
Rich
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Anderson Takemitsu Kubota" <[email protected]>
| Subject: How to implement the Socket Timeout when receiving data?
| Date: Mon, 30 Jun 2003 12:24:38 -0300
| Lines: 24
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 200.189.66.138
| Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa09.phx.gbl
microsoft.public.dotnet.framework.compactframework:9493
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi!
|
| I read some posts on this group about this topic and I saw I need to
| implement the close in a timer event.
| Can anybody help me for this? I don't know how to do it.
|
| This is a sample code that I am using:
|
| while (true)
| {
| bytes = cSocket.Receive(buffer, buffer.Length, 0);
| output.Write(this.buffer,0,this.bytes);
| if ( this.bytes <= 0)
| break;
| }
|
| The problem is that if I lost connection in the while block the
| cSocket.Receive doesn't return any value and freezes the application.
|
| Thank you.
|
| Anderson T. Kubota
|
|
|