blocking function call
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-io' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

dave wanta (VIP)
hi all,
I have a code snippet that I don't know how to handle, and am looking for direction, examples, etc....

I have some code that could hang indefinitely, and what I need to do is stop the code from executing if it doesn't execute within n milliseconds.

here is an example.

//build and construct a socket...
// socket code here....
// everything works great..
// but if the socket doesn't get a response back, everything hangs....

socket.ReceiveFrom( UdpPacket, 0, 1024, SocketFlags.None, ref tempRemoteEP );

the socket.ReceiveFrom() method may never actually execute, because it is waiting for a packet back from the UDP (DHCP server) server. What I would like to do is wait for n milliseconds, and if the code doesn't execute, then continue with the execution of the program and handle not getting a response back.

What do I need to do, to achieve this?

Thanks,
dave
Reply to this message...
 
    
Devin Rader
Don't know if this thread will help or not..

http://groups.google.com/groups?q=ReceiveFrom+wait+time+group:*dotnet*
<http://groups.google.com/groups?q=ReceiveFrom+wait+time+group:*dotnet*&hl=e
n&selm=14c22f48.0201270524.269b05f4%40posting.google.com&rnum=1>
&hl=en&selm=14c22f48.0201270524.269b05f4%40posting.google.com&rnum=1

(watch wrapping)

Devin

-----Original Message-----
From: dave wanta [mailto:Click here to reveal e-mail address]
Sent: Monday, May 13, 2002 12:47 PM
To: ngfx-io
Subject: [ngfx-io] blocking function call

hi all,
I have a code snippet that I don't know how to handle, and am looking for
direction, examples, etc....

I have some code that could hang indefinitely, and what I need to do is stop
the code from executing if it doesn't execute within n milliseconds.

here is an example.

//build and construct a socket...
// socket code here....
// everything works great..
// but if the socket doesn't get a response back, everything hangs....

socket.ReceiveFrom( UdpPacket, 0, 1024, SocketFlags.None, ref tempRemoteEP
);

the socket.ReceiveFrom() method may never actually execute, because it is
waiting for a packet back from the UDP (DHCP server) server. What I would
like to do is wait for n milliseconds, and if the code doesn't execute, then
continue with the execution of the program and handle not getting a response
back.

What do I need to do, to achieve this?

Thanks,
dave
| [ngfx-io] member Click here to reveal e-mail address = YOUR ID |
http://www.aspfriends.com/aspfriends/ngfx-io.asp = JOIN/QUIT
Reply to this message...
 
 
System.Net.Sockets.SocketFlags




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com