Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

ASynch sockets race

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
paul moore - 07 Jun 2007 00:29 GMT
I have a fully asynch socket server application. I find however that
sometimes it locks up.
The client sends me a packet before I have posted a BeginRead. My beginread
then completes but I never get called back. Both sides end up waiting for
each other.

THe IAsyncResult return by BeginRead has IsCompleted=false

At first I thought it might be becuase I was doing some sycn IO during
client connection but I have made that all async too and I still get the
occasional lockup

I am sure I am doing something dumb but I cant see what. I always fail if my
trace show client send packet followed by server beginread but if the 2
process time just slighly differnt and I get server beginread then client
send packet then all is fine.

If I kill the client and run it again all is fine. The server pending
callback is invoked saying that the socket closed and the server cleans up
OK. Then we get into the same race with this next client
Peter Duniho - 07 Jun 2007 00:57 GMT
> I have a fully asynch socket server application. I find however that  
> sometimes it locks up.
> The client sends me a packet before I have posted a BeginRead. My  
> beginread
> then completes but I never get called back. Both sides end up waiting  
> for each other.

Well, as you might guess, that shouldn't be a problem.  Once the socket is  
connected, it should not matter whether the server has actually posted a  
receive yet, the data should still get through once the receive has been  
posted, eventually.

I do suspect you've got a bug in your own code, but since you didn't post  
any code it's hard to say.  The usual practice is to post a  
concise-but-complete sample of code that reliably reproduces the problem.  
If you do so, then perhaps you'll be able to get a better answer.

By the way, I will note that I'm assuming you have a connection-oriented  
socket (eg TCP), since you mention a "connection" and closing the  
connection.  However, if you are using UDP then the behavior you're seeing  
is not necessarily unexpected, and you need to code around the possibility  
of not receiving data (among other things).

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.