Author Topic: TCP Connection  (Read 7714 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
TCP Connection
« on: December 18, 2008, 11:39:39 AM »
Hi Mark,
  I have one TCP socket connected to my PC application server, which works excellent. I tested it by simply restarting the process (reset button, and power off/on), to see if the connection can be restablished from fresh again. But as soon as a connection is attemted by :
fnTCP_Connect(TCPsocket, IP, 21000, 0, 0);

I get a TCP_EVENT_ABORT message. Even if I restart the server application this happens. A connection can be remade after the system is left off for a few minutes and restarted (the server application doesnt have to be closed).

Before a connection is attempted, I wait 4 seconds allowing for initialisation then proceed with a connection. I am able to connect after a TCP_EVENT_ABORT message is received, is this normal? Do I place the line fnTCP_close(Socket); here, even though when resetting the processor a connection hasnt been made?

Regards
Neil



Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: TCP Connection
« Reply #1 on: December 19, 2008, 11:45:07 PM »
Hi Neil

Can you check the port number that your application is using when it tries to establish the connection? Check with Wireshark the first (successful) connection and then the second (unsuccessful) one. I assume that the abort is received due to the fact that the PC TCP stack is sending a RESET back when the connection attempt is made (do you see this?).

When you reset the board the original TCP connection still exists. It may be that the PC server doesn't allow more than one connection at the same time (?). Or it may be that the board is using the same port number for teh second connection attempts, which will probably be rejected.

If the second case is true it may be that the random number generator used to generate the port number used by the client is repeating the same value after resets(?).

Regards

Mark