Multiple BSD connections

Hi,

To establish more connections using BSD sockets, I need to determine the best approach.

1)Should I implement multiple threads for this purpose? For example, I could use a threading model similar to the following:

https://www.keil.com/pack/doc/mw6/Network/html/group__bsd__routines.html#ga7005ffbeeff92be5394ff3244da79028

2) Alternatively, should I create a server thread and utilize the listen function with a backlog argument greater than 1? If that’s the case, I would need to manage incoming connections using the accept function to ensure they are handled.

3) As I see the Network debug window details, there is a bsd_cb_tcp callback function, but there is no information on how to implement or use it, Is there any resource?

4)How can I get the BSD socket states, such as Established, Connected, or others?"

5)Is there a function to determine the amount of available memory

Parents
  • 1+2) Sorry, don't know what fits best in your application purpose. So I also can't give a recommendation.

    3) As the BSD socket implementation uses the network libraries own native TCP and UDP sockets, they internally also use the callbacks to maintain BSD socket operation. You do not need to deal with it.

    4) Not sure how perfect this works, be maybe you can poll a socket with non-blocking recv() calls and check the returned state. Or, maybe getpeername() might help. If it returns a valid peer, the socket should still be up.

    5) Not sure what memory you mean.

Reply
  • 1+2) Sorry, don't know what fits best in your application purpose. So I also can't give a recommendation.

    3) As the BSD socket implementation uses the network libraries own native TCP and UDP sockets, they internally also use the callbacks to maintain BSD socket operation. You do not need to deal with it.

    4) Not sure how perfect this works, be maybe you can poll a socket with non-blocking recv() calls and check the returned state. Or, maybe getpeername() might help. If it returns a valid peer, the socket should still be up.

    5) Not sure what memory you mean.

Children