nonblocking socket connect() fails

H

Houston Keach

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
 
A

Alex Feinman [MVP]

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.
 
M

Mike Boilen [MS]

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.gotdotnet.com/team/netcf/FAQ.aspx

--------------------
| 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.supernews.com
| Message-ID: <[email protected]>
| 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: (e-mail address removed)
| 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
|
 
H

Houston Keach

On Fri, 05 Sep 2003 16:50:12 -0500, Houston Keach <> wrote:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top