sockets
-
does anybody have a link to a tutorial that is tried and tested and simple and accurate and etc. :P on how to use sockets in c#? what i need to do is to connect to a specific ip on a certain port, send info and recieve and process it, then send more depending on what's been sent etc. what type of connect is also best to use? thanks. ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
-
does anybody have a link to a tutorial that is tried and tested and simple and accurate and etc. :P on how to use sockets in c#? what i need to do is to connect to a specific ip on a certain port, send info and recieve and process it, then send more depending on what's been sent etc. what type of connect is also best to use? thanks. ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
There are several good ones here - use the ratings to see what people think is good. As far as the protocol, that is defined entirely by you. Sockets are a simple connection between, well, sockets. That's it. More than likely, you'll want to use a
TcpClient
if you want to use TCP/IP for the connection protocol. What comes across the wire is defined by you, however. Tons of protocols including HTTP, SMTP, FTP, etc. all use TCP/IP, but the protocol - the messages sent back and forth - is unique to each (though some common approaches exist, such as headers vs. body). In fact, someone earlier today simply asked about "telnet". Telnet is really just a simple TCP socket connection with know particular protocol. A good way to handle this is to connect using aTcpClient
and getting aNetworkStream
by callingTcpClient.GetStream
. Instantiate aStreamWriter
andStreamReader
on that stream with an agreed-upon encoding (like ASCII, UTF8, Unicode, etc.). Send and receive commands. A good protocol will define errors codes that typically prefix a response message, making it quick and simple for you to determine if a command passed or failed. For good examples of such protocols, I recommend you search http://www.ietf.org/rfc[^] for RFCs describing TCP protocols like SMTP, HTTP (pretty easy one), FTP, etc. I would recommend DICT (http://www.ietf.org/rfc/rfc2229.txt[^]), which I'm currently wrapping (slowly, with low priority). It's a simple protocol and gives you a pretty good idea of a good protocol design.Microsoft MVP, Visual C# My Articles
-
does anybody have a link to a tutorial that is tried and tested and simple and accurate and etc. :P on how to use sockets in c#? what i need to do is to connect to a specific ip on a certain port, send info and recieve and process it, then send more depending on what's been sent etc. what type of connect is also best to use? thanks. ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
This article http://www.codeproject.com/csharp/pop3client.asp[^] will help a lot because it is simple, uses sockets to send and receive data with a pop3 server (which is cleartext)... exactly what you want. The best part is, if you're just doing this to learn, you dont need to write the server piece! Microsoft .NET - Come on! I need the Traffic!
-
does anybody have a link to a tutorial that is tried and tested and simple and accurate and etc. :P on how to use sockets in c#? what i need to do is to connect to a specific ip on a certain port, send info and recieve and process it, then send more depending on what's been sent etc. what type of connect is also best to use? thanks. ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
make a little pop3 class to talk to your email server and read your messages etc. You coul make a class for all the pop commands like AUTH, LIST etc. Read the pop3 rfc, its very simple. I did something like this, and it was a fun way to learn .net sockets... /\ |_ E X E GG
-
does anybody have a link to a tutorial that is tried and tested and simple and accurate and etc. :P on how to use sockets in c#? what i need to do is to connect to a specific ip on a certain port, send info and recieve and process it, then send more depending on what's been sent etc. what type of connect is also best to use? thanks. ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
thanks all. :) ------------------------------------------------------- ithium is the best. 'Science without religion is lame, religion without science is blind.' --Albert Einstein 'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein