System.Net.Sockets Quickie

  • Thread starter Thread starter Jm
  • Start date Start date
J

Jm

Hi All

Im trying to get a bit of background info on .net.sockets for an app that im
upgrading to be .net. Under vb6 i used the winsock control and would start
it listening and it would call an event once the connection attempt is made
to it and you would do all you had to do, close the connection and reopen. I
cant seem to find out how this works with .net.sockets. The code i have seen
seems to always talk about listening only the once for the connection and
once done using the connection it closes the connection and ends the
program. Im assuming it is possible to reopen the connection without exiting
the program and wait for another connection ? Any help is greatly
appreciated

Thanks
 
Hi All

Im trying to get a bit of background info on .net.sockets for an app that im
upgrading to be .net. Under vb6 i used the winsock control and would start
it listening and it would call an event once the connection attempt is made
to it and you would do all you had to do, close the connection and reopen. I
cant seem to find out how this works with .net.sockets. The code i have seen
seems to always talk about listening only the once for the connection and
once done using the connection it closes the connection and ends the
program. Im assuming it is possible to reopen the connection without exiting
the program and wait for another connection ? Any help is greatly
appreciated

Thanks

There are a couple of ways to accomplish your task... The best way,
IMHO, is to make use of the BeginXXX methods on the System.Net.Socket
class.

Here is a good starting place for information on using .NET sockets:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsockets.asp

You will want to look particularly at the "Listening with Sockets"
section. You'll find that it will expose you to both Syncronous and
Asynchronous server sockets. Using async sockets requires a tad more
coding - but ultimately it is the most effeceint.
 
Back
Top