I'm creating an asynchronous socket programming in vb.net. i've utilised the code from Asynchronous client and server code from the following links:
http://msdn.microsoft.com/en-us/library/fx6588te.aspx for server program
The client program is present as per http://msdn.microsoft.com/en-us/library/bew39x2a.aspx.
When I try to connect the for more than one client the second client always waits until the first client completes the call. I want the clie开发者_StackOverflow社区nts to accept calls at the same time.
Does WCF help to make multiple clients to accept calls at the same time? If so what is WCF and how will it help. Or is there any other concept which can help?
Yes, WCF can help you there. But it implements only well known protocols like SOAP, WS-*, JSON, and a few proprietary ones like binary TCP binding.
You'd only use async socket programming if you need
- High scalability (more than 20 simultaneous clients)
- A custom protocol
If you build on top of HTTP, I recommend the HttpListener class
If you need a custom protocol with a few clients, use synchronous socket programming with multiple threads.
If you still want to implement a server with async sockets, then you need a continuous loop that accepts connections (after EndAccept()
immediately call BeginAccept()
again) and then start the BeginReceive()
I can tell you from experience though that debugging such a server is not easy. It's quite hard to follow the chain of events even through a detailed log file. Good luck with that :)
精彩评论