views:

3462

answers:

7

I'm porting old VB6 code that uses the Winsock control to C#. I haven't done any socket programming and I wonder if anyone has a good reference/tutorial/howto that I can use to start getting up to speed.

I'm appealing to the hive mind while I proceed with my generally unproductive googling.

I'm using UDP, not TCP at this time.

A: 

MSDN is a good place to start

Are you working on: a client (TCPClient) or a server (TCPListener)

stephenbayer
A: 

Code Project has a great tutorial

hometoast
+2  A: 

The August 2005 MSDN Magazine had an article about System.Net.Sockets and WinSock:

http://msdn.microsoft.com/en-us/magazine/cc300760.aspx

jeffm
wow. I remember that one, that was a really good article.
stephenbayer
A: 
Thomas Bratt
A: 

Just a heads up:

I would recommend first working with TCP rather than UDP. UDP doesn't automatically redeliver lost packets like TCP so it will add another element to the equation that will probably just confuse you as you're just starting out.

Building a socket client is relatively easy using the TCPClient class available in the .Net library. TCPListener is easy enough to use for a single client but if you're hoping to develop some server type application (IE: Handling multiple connections.) the real hurdle you'll have to overcome is understanding multithreading.

Once you've played around with single connection sockets I suggest you read up on multithreading.

Spencer Ruport