473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with AcceptCallback closing server socket

Having:Socket mysocket = new Socket
(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

I cannot execute mysocket.Close() after executing
mysocket.BeginAccept(new AsyncCallback(ServerAcceptConn)..

The system complains giving a hint "AcceptCallback"

What should I execute before closing to not have this
error message?
Thanks.

Nov 15 '05 #1
1 3133
"David" <da**********@eds.com> wrote in message news:<04****************************@phx.gbl>...
Having:Socket mysocket = new Socket
(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);

I cannot execute mysocket.Close() after executing
mysocket.BeginAccept(new AsyncCallback(ServerAcceptConn)..

The system complains giving a hint "AcceptCallback"

What should I execute before closing to not have this
error message?

David -

I made a response to this earlier, but I don't see it posted, so
either something went wrong, or you will see two responses from me.
Sorry about that.

When the socket object is closed with an outstanding BeginAccept()
method, the AsyncCallback method will be automatically fired, and the
EndAccept() method will throw an ObjectDisposedException. You need to
catch that using a try-catch block, and handle it accordingly. Hope
this helps solve your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: flupke | last post by:
Hi, I have a gui (made in wxPython) that enables a user to connect to a server and issue some commands. The problem occurs when i try to disconnect the client. It exits but it doesn't return to...
0
by: J Brad | last post by:
Hi every body I wrote a Asynch Server using ManualResetEvent.Reset(), ManualResetEvent.Set(), ManualResetEvent.WaitOne() events I'm receiving a Message (Example: "Hello Word") without Terminator...
0
by: Dave | last post by:
why does this codesnippet block until the acceptcallback has completed. According to the microsoft documentation the beginaccept callback method executes in a separate thread, and is called...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
4
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with...
2
by: Ajay | last post by:
Hi I am writing an SMTP server in VB.Net using the as Async Socket Server Code in MSDN as the base. My problem is that the port 25 socket Listener just stops accepting connections after 10 to...
0
by: Ben | last post by:
I modified the logmonitor sdk example so it would work over a network. It works great when the client and server are running on the same PC and have administrator privileges. So I have two...
10
by: Clayton | last post by:
Hi all, I'm trying to develop a server that listens to incoming calls using the asycnhronous methods BeginAccept / EndAccept. I start the server (till this point it is ok) and few seconds later...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.