socket programming using c#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nagasrinivas05
    New Member
    • Feb 2008
    • 8

    socket programming using c#.net

    hi,
    this is srinivas here i am using socket programming to send data to a remote computer using clssocket with namespace system.net and it is working well, but when i am sending continuous data in a packet format to one more remote computers there i am facing the problem of mixing status
    one packet format is #010211*
    other is $010228&&&&1111 *
    using visual studio 2005 , oracle 10g
    when continuously sending the packet data is been mixed
    pls help me in solving the problem of mixing data
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    UDP packets are not garunteed to arrive in any sort of order.
    Use a TCP/IP connection (socketstream) if you want to garuntee data sent out arrives in the same order.

    Comment

    • nagasrinivas05
      New Member
      • Feb 2008
      • 8

      #3
      Hi Plater,
      Thank u for u r response....
      but i am using Tcp/ip connection and my server ip is 192.168.1.1, port no -8821
      and client suppose 192.168.1.4 or 192.168.1.54 etc.....
      but still whatever the packet i receive on server they get mixed on server side
      how to resolve this problem........ ....

      Regards
      srinivas

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Uhh, I would say it is a problem in either how you are sending the data or how you are receiving the data, because they come in in the same order they go out.

        Comment

        • nagasrinivas05
          New Member
          • Feb 2008
          • 8

          #5
          hi plater,
          Sorry for the trouble.
          the sending and receiving data are working fine but when we are sending data packets continuously within milli seconds then the data is being mixed.
          i want to know whether we can use lock() concept and does it effect the performance.... ...............
          its urgent pls.


          Thanks & Regards
          Srinivas

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Are you using threads / events to trigger data sending? Because there is no garuntee there who goes first.
            Go look into Mutex objects if you really need to do the locking, they're good for that kinda thing.

            Comment

            • nagasrinivas05
              New Member
              • Feb 2008
              • 8

              #7
              hi Plater,
              when i am closing the application and again starting the application getting message that only one usage of each socket address(protoco l/network/address/port) is normally permitted and i want the port number also when i close the application

              Regards,
              Nagasrinivas

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Sounds like you are not correctly closing the socket(s) when you exit your program.
                Perhaps a thread is still running?
                Also: If you close a socket that then gets data sent to it when its still in "closing" state, the port that socket used stays locked down for a some timeout period. I believe there is a .SocketOption you can set to avoid that. Something like "NoLinger" I think.

                Comment

                Working...