nonblocking socket connect() fails

nonblocking socket connect() fails

Post by Houston Ke » Sun, 07 Sep 2003 06:50:12


The following code succeeds in the full dotnet framework but fails
when run in the compact framework. That is to say it throws the
expected "SocketException" in the full framework but throws the
mysterious
"System.InvalidOperationException:InvalidOperationException" under the
compact framework.

//////////////////////////////////////////////////////////////////////////
IPEndPoint EndPoint = new IPEndPoint( IPAddress.Parse("172.20.20.26"),
int.Parse("12345"));
Socket ClientSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
ClientSocket.Blocking = false;
{
ClientSocket.Connect( EndPoint );
}
//////////////////////////////////////////////////////////////////////////

My reading of the Socket class docs seems to suggest that non-blocking
IO should be supported in CF. Any ideas?

--Houston Keach
 
 
 

nonblocking socket connect() fails

Post by Houston Ke » Sun, 07 Sep 2003 07:52:44

It works as expected when left in default blocking mode.

On Fri, 5 Sep 2003 15:37:51 -0700, "Paul G. Tobey [eMVP]"

 
 
 

nonblocking socket connect() fails

Post by Alex Feinm » Sun, 07 Sep 2003 08:17:12

Currently the only supported value for Socket.Blocking under CF is true.
Docs saying it is supported on CF means that the property is present and
using it will not cause compile errors.
 
 
 

nonblocking socket connect() fails

Post by mboile » Thu, 11 Sep 2003 02:30:49

If you set Blocking to true, then you can use either Connect or
BeginConnect. If you set Blocking to false, then you can only use
BeginConnect. If you'd like to do asynchronous I/O, you should use the
Begin functions (BeginConnect, BeginSend, etc).

Mike Boilen
Developer
NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.yqcomputer.com/

--------------------
| From: Houston Keach <>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: nonblocking socket connect() fails
| Date: Fri, 05 Sep 2003 16:50:12 -0500
| Organization: Posted via Supernews, http://www.yqcomputer.com/
| Message-ID: < XXXX@XXXXX.COM >
| X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| X-Complaints-To: XXXX@XXXXX.COM
| Lines: 22
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!npeer.de.kpn-eurorings.net!in.100proofnews.com!in.100proofnews.com!cycl
one.bc.net!sjc70.webusenet.com!news.webusenet.com!sn-xit-02!sn-xit-04!sn-xit
-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32899
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| The following code succeeds in the full dotnet framework but fails
| when run in the compact framework. That is to say it throws the
| expected "SocketException" in the full framework but throws the
| mysterious
| "System.InvalidOperationException:InvalidOperationException" under the
| compact framework.
|
| //////////////////////////////////////////////////////////////////////////
| IPEndPoint EndPoint = new IPEndPoint( IPAddress.Parse("172.20.20.26"),
| int.Parse("12345"));
| Socket ClientSocket = new Socket(AddressFamily.InterNetwork,
| SocketType.Stream, ProtocolType.Tcp);
| ClientSocket.Blocking = false;
| {
| ClientSocket.Connect( EndPoint );
| }
| //////////////////////////////////////////////////////////////////////////
|
| My reading of the Socket class docs seems to suggest that non-blocking
| IO should be supported in CF. Any ideas?
|
| --Houston Keach
|
 
 
 

nonblocking socket connect() fails

Post by Houston Ke » Thu, 11 Sep 2003 07:46:46


Thanks, all, for the clarification. I was actually trying to execute
a non-blocking connect in the current thread so I could time out in a
reasonable time period but I managed to achieve the same result with
BeginConnect and then polling in a timed loop.

--Houston Keach