Re: Expert Input for Asynchronous Socket

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 10/11/04


Date: Mon, 11 Oct 2004 17:32:09 -0400

Most likely your overwriting the IPAddress in an overlapped previous
callback before the current SentTo can send or something like that. Would
probably need to post the code or a small but complete sample of the code
that shows the problem.

-- 
William Stacey, MVP
"Chan" <hifchan@yahoo.com> wrote in message
news:fe01f62a.0410111326.55c32c3b@posting.google.com...
> Building an Asyc Socket DLL using C#, I followed MS .NET FRAMEWORK
> library sample (see "Asynchronous Client Socket Example") and created
> a DLL called MSSock. I then reference MSSock in a .exe c# program to
> test it.
>
> This .exe has a form which has a button and a text field to invoke the
> DLL async communication and display return data.
>
> <F5>, runs ok and data returned is being displayed. Without exiting
> the app, click on the button again, this supposed do exactly connect,
> send, receive, close and displaying data. But, the following comes up
> in a dialog box,
>
> --------------------------------------------------------------------------
--
> An unhandled exception of type 'System.Net.Sockets.SocketException'
> occurred in netsock.dll
>
> Additional information: A request to send or receive data was
> disallowed because the socket is not connected and (when sending on a
> datagram socket using a sendto call) no address was supplied
> --------------------------------------------------------------------------
--
>
> Ok, I set a breakpoint at the line the DLL is called, stepping through
> all of the lines, it ran perfectly fine, no error, returns data as
> expected.
>
> It's repeated many times with machine rebooting. I opened up a DOS
> window, use
>
>     netstat -p TCP
>
> to check socket connection statistics, whenever I got the above error,
> netstat showed the State as ESTABLISHED.