Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. sockets

sockets

Scheduled Pinned Locked Moved C#
csharptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    surgeproof
    wrote on last edited by
    #1

    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

    H G E S 4 Replies Last reply
    0
    • S surgeproof

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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 a TcpClient and getting a NetworkStream by calling TcpClient.GetStream. Instantiate a StreamWriter and StreamReader 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

      1 Reply Last reply
      0
      • S surgeproof

        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

        G Offline
        G Offline
        GISnet
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • S surgeproof

          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

          E Offline
          E Offline
          eggie5
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • S surgeproof

            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

            S Offline
            S Offline
            surgeproof
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups