Socket Programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pschulz
    New Member
    • Mar 2008
    • 4

    #1

    Socket Programming

    Dear All,

    I am new in this forum and also relatively new to .Net. I need to create an application which needs to be able to act as a network server and provide data and messages to a variety of clients including IMAP email clients.

    I am using Visual C# and .Net version 2.0.

    The .NET socket interface looks somewhat easy but it there seems little control of the details. I can not design both sides of the network comm, i.e. my server must be able to connect to any TCP client written by whoever - so I must can not implement simple application layer protocols but rather must rely only on for example what the IMAP or HTTP RFCs say.

    Two key problems I would like some help with is:

    (1) I need network events so that I can initiate a READ on sockets when network data arrives. Having to get a thread looping all the time to check seems wasteful to me. I cannot find any such network event.

    (2) I am getting / sending limited size messages (i.e. it's not Megabytes) over the network but can not include total message size into the data. However, TCP/IP knows when all the packets of a certain messages have been transmitted and the transmission of that specific message is completed and acknowledged as far as TCP is concerned. However, this info seems unavailable on the programmer level in .NET. Or isnt it?
    I can keep checking for socket.Availabl e() in my code but I must know that a specific message is now over, and that the next data now Available() is actually a new message.

    I already searched MSDN and the .NET Help but seems nothing documented.
    Any hint is appreciated.

    Regards

    Peter
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET forum.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      TCP/IP provides mechanisms to ensure all bytes sent out arrive at their destination and in the correct order.
      It does not specifically know how many of those bytes are associated with one .Send() call vs another.
      That is were the protocals come in.
      Both IMAP and HTTP have delimantors to know when a message is over.
      HTTP also has a special header (IMAP may have one too but I haven't done a lot of IMAP) that tells you have many bytes are going to be in the message.

      Your socket handling will be capable of knowing that MessageA came from computer1 and MessageB came from computer2 (RemoteEndPoint )

      Comment

      Working...