469,613 Members | 1,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

Expert Input for Asynchronous Socket

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.
Nov 16 '05 #1
1 6027
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" <hi*****@yahoo.com> wrote in message
news:fe**************************@posting.google.c om...
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.


Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Richard | last post: by
7 posts views Thread by Colin | last post: by
4 posts views Thread by taskswap | last post: by
reply views Thread by Macca | last post: by
2 posts views Thread by Nicolas Le Gland | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.