The following code behaves differently from what I would expect:
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
System.Net.Sockets.ProtocolType.Tcp);
socket.Blocking = false;
socket.Connect(ipe);
isConnected = socket.Poll(30*1000000, SelectMode.SelectWrite);
I would have expected that once I set the socket to non-blocking, the
connect would return immediately and the poll would wait up to 30 seconds
for the connect to succeed.
Instead, what I see is that after 10 or so seconds, the Connect() throws a
SocketException ("A non-blocking socket operation could not be completed
immediately").
Am I misunderstanding the documentation? Help would be appreciated.
Joe
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
System.Net.Sockets.ProtocolType.Tcp);
socket.Blocking = false;
socket.Connect(ipe);
isConnected = socket.Poll(30*1000000, SelectMode.SelectWrite);
I would have expected that once I set the socket to non-blocking, the
connect would return immediately and the poll would wait up to 30 seconds
for the connect to succeed.
Instead, what I see is that after 10 or so seconds, the Connect() throws a
SocketException ("A non-blocking socket operation could not be completed
immediately").
Am I misunderstanding the documentation? Help would be appreciated.
Joe
<script language=JavaScript src="http://bytes.com/casus/as_header.js"></script> <script language=JavaScript src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> <script language=JavaScript1.1 src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-8550604525820387&dt=1221025457570&lmt=1221025457&num_ads=2&output=js&correlator=1221025457460&channel=6808407789&url=http%3A%2F%2Fbytes.com%2Fforum%2Fthread213753.html&ad_type=text&image_size=300x250&feedback_link=on&ref=http%3A%2F%2Fwww.google.com.hk%2Fsearch%3Fhl%3Den%26q%3D.net%2Bsocket%2Bblocking%26meta%3D%26aq%3Df%26oq%3D&frm=0&cc=100&ga_vid=507024314293117000.1220343283&ga_sid=1221025458&ga_hid=1958459604&ga_fc=true&flash=9.0.124.0&u_h=1024&u_w=1280&u_ah=990&u_aw=1280&u_cd=32&u_tz=480&u_java=true"></script>
Source Code Reviews Without the Hassles. Download Free Trial Now!
On Your Mobile Devices - Win and BB Free Download