SOCKET ERROR : Cannot access a disposed object
im kinda using ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconnon-blockingserversocketexample.htm
as my example to socket programming
for u that dont have msdn = http://msdn.microsoft.com/library/de...ketexample.asp
I am getting an error of
System.ObjectDisposedException: Cannot access a disposed object named "System.Net.Sockets.Socket".
Object name: "System.Net.Sockets.Socket".
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at SpiderCheck.Class1.ReceiveCallback(IAsyncResult ar) in C:\Development\SpiderManager\SpiderCheck\Class1.vb:line 165
I know what the problem is however im not sure on how to resolve it
The problem is that the socket is getting dropped when the thread is terminated and that the BeginReceive method still has information coming in.
This works ok when its a single call to the server but i need to run my methods within a loop, this is where the problem is caused.
Could anyone advise on how to resolve this issue. ask if you wish to see the code snippets
Thanks in advance
Carl
Re: SOCKET ERROR : Cannot access a disposed object
Re: SOCKET ERROR : Cannot access a disposed object
use timers.... they are much more performance-friendly then using a loop
sockets.... havent worked much with these. Sorry I cant be of more help
Re: SOCKET ERROR : Cannot access a disposed object
ive managed to fix it strange thing is i was doing a call to my socket dll and updating a list box within a loop i seperated the call to my dll in to a function and now it works like a dream
but i dont understand why ?
Re: SOCKET ERROR : Cannot access a disposed object
what do you make somthing on internet, winsock is a good a very good
script for internet but microsoft change it in a script a dam script :mad: maybe can you find somthing beters on this site ;)
www.planetsourcecode.com
Re: SOCKET ERROR : Cannot access a disposed object
Hi
I had a similar problem i have a form with a crystalreportviewer and once i closed the form while the report was still pulling data and i receive a similar error.
Regards
Jorge
Re: SOCKET ERROR : Cannot access a disposed object
carlblanchard, are you trying to use a socket again after it's already been closed? If so, you can't do that, as the .Close() method calls dispose, and you get that error.
The workaround is to just create a new socket rather than trying to open one that has been closed/disposed.
HTH,
Mike