Port reused error not reaching application

Hi, I have a modem that creates a client connection to a server. It works fairly well. I have now started testing failure modes (disconnection the antenna and remove the SIM card etc).

The disconnect is eventually handled properly (I stop and close the bearer and then restart it). The problem comes in when I try and create the socket connection. The modem seems to reuse previous port numbers (at least I assume it is the modem selecting the port.) and the server (within the windows drivers) is rejecting the connect. Wireshark report “TCP Port numbers reused”.

The modem calls wip_TCPClientConnect and then nothing happens. I wait forever for an error event or a connect. Neither happens…

My question is

  1. how to I detect the above error?
  2. what do I do about it once I get it?
  3. how do I avoid the situation altogether?

PS. I see it eventually timed out after 10mins… is it possible to improve on this? 10min wait is not really ideal…



Out of curiosity, I tried googling “TCP Port numbers reused”, and found these:

wireshark.org/lists/wireshar … 00304.html

ask.wireshark.org/questions/1795 … ers-reused

Not sure where that gets you, though… :confused:

Hi Awneil, the second post is interesting. They suggest that because I am capturing the network traffic (i.e. with Wireshark) the connections are not being closed and therefore the port end up being reused… (I am cycling connected and disconnects for testing reliability)

Has anyone else noticed that effect?

I am now getting muddled… I am now getting “TCP connection refused by server” which is a lot more helpful… Wireshark still reporting previous error… I will try recreate the problem without running Wireshark (although I then can’t tell if it is a port reused issue… great :cry: )…



If you use a windows client, and reboot it between connections, does that give the same “port re-used” effect…?


Have a look at the parameters available in the wip_netSetOpts(). You can change the timeout and retransmit values using this call as you are setting up the WIP stack.

ciao, Dave

Hi Dave and Awneil, thanks for your posts. It seems to be working OK now. Wireshark seems to have caused a bit of the problem. But I am not entirely clear on why of if it is entirely down to that. Dave I will try adjusting the timeouts etc, which I want to do anyway…