tcp_listen() can only run 4 times before it fails

I am trying to let multiple devices connect to my BL2500. If I set NUMSOCKETS to 5 tcp_listen returns 0 the fifth time it is called. 4 clients can connect, when one of them exits gracefully I call tcp_listen() it returns 1 claiming success but when I attempt to connect a 5th time I get a reset ack, even if there is no devices currently connected to it. I really just need to know if there is something special I need to do to recycle the sockets after the disconnect. Only allowing 4 devices to connect at once is annoying but I can get by, the real issue is having to reset the controller after 4 connections have been made.

#define NUMSOCKETS 5


Hi jtokarz,

I was wondering if you ever came across an answer for this? I’ve run in to the same problem and can’t find any resolution on the web.

Hi edg10,

The problem here is that you are calling the tcp_listen function within the data handler, if the DC 9 TCP code is similar to the DC10 code, after calling the data handler with the TCP_DH_CLOSED event, the library removes the link to the data handler.

This means the data handler set from within in your data handler is removed and the socket is not configured correctly.

You need to call the tcp_listen() from outside the data handler so maybe set a flag in the data handler to let your apps main code initiate a new tcp_listen()



You should be using Dynamic C 10.72 and the new TCP patch

Hi Peter, exactly the issue! I added a flag in the TCP_DH_CLOSED event of my callback and restarted tcp_listen outside the data handler. I can now connect/disconnect/reconnect without problems.

Thanks MargaretK. My board is a BL2600, I think the last version that supports the 3000 CPU was DC9.62 ?

My Apology, I misread