1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Server connection problem

Discussion in 'C#' started by Frederick Lupien, Aug 31, 2010.

  1. Frederick Lupien

    Frederick Lupien New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi.

    I have an client / server application that works perfectly well when the client runs in c#. Problem is that the real client is a PIC microprocessor and we are unable to connect to our C# server using the PIC. Using wireshark to monitor the network packet, it seems that the C# client and the PIC client both send identical SYN packet for the initial connection (we even facked the MAC address at one point to make the packet as identical as possible) but the server ignores them.

    Here is the server listening code:

    Code:
     	void StartListen()
            {
                try
                {
                    // Create the listening socket...
                    m_oMainSocket = new Socket(AddressFamily.InterNetwork,
                                              SocketType.Stream,
                                              ProtocolType.Tcp);
                    IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, 5000);
                    //m_oMainSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, false);
                    // Bind to local IP Address...
                    m_oMainSocket.Bind(ipLocal);
                    // Start listening...
                    m_oMainSocket.Listen(4);
                    // Create the callback for any client connections...
                    m_oMainSocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
    
                }
                catch (SocketException se)
                {
                    CLog.Log(se.Message);
                    System.Diagnostics.Debugger.Break();
                }
    
            } 
    
    Here is the correct packet exchange using the C# client (.140 is the client, .154 is the server)


    Code:
    179        34.341466        192.168.0.140        192.168.0.154        TCP        58868 > commplex-main [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2
    180        34.341579        MacAddressServer        Broadcast        ARP        Who has 192.168.0.140?  Tell 192.168.0.154
    181        34.342439        MacAddressClient        MacAddressServer        ARP        192.168.0.140 is at MacAddressClient
    182        34.342447        192.168.0.154        192.168.0.140        TCP        commplex-main > 58868 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460 WS=8
    183        34.342724        192.168.0.140        192.168.0.154        TCP        58868 > commplex-main [ACK] Seq=1 Ack=1 Win=65700 Len=0 
    
    And here the single PIC packet the does not trigger the server response. It's the same expect for the frame number, ID and checksum:
    Code:
    65        15.696625        192.168.0.139        192.168.0.154        TCP        53650 > commplex-main [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2 
    
    I have been working on this all day without any progress. Any help greatly appreciated.

    I can post the wireshark complete wireshark log if necessary.
     

Share This Page