WINC1500 TCP Socket Bind & Close
I'm confused by the network socket 'Bind' and 'Close' operations, and was wondering if I could get some clarification on how to use them.
I implemented the Microchip MLA's TCP Server example on a WINC1500 Access Point (AP), and I already know my local host's IP and Port number to start AP mode. Do I need to wait until a remote TCP Client connects before calling the 'Bind' function? The MLA's TCP Server example waits until the client connects before doing the 'Bind', but I don't understand why.
I thought that the 'Bind' operation simply ties my AP's IP and TCP Server Port number together, to send them to a remote client that connects, so it'll know what IP and Port destination to send packets to. I thought the host TCP Server's 'listen' socket was independent of the remote TCP Client's IP and Port number.
I'm also unclear about how to handle remote TCP Client socket disconnects, whether from a socket callback "receive" event indicating a negative message length, or from a wifi callback "M2M_WIFI_CONN_STATE_CHANGED_EVENT" event. The MLA example code closes the remote TCP Client socket, but does _not_ close the local TCP Server socket.
I understand the problem with not closing TCP Client sockets--there are seven of them--and if you don't re-use them by closing them you'll eventually run out. But is anything wrong with leaving the TCP Server's 'listen' socket open indefinitely? If not, would I need to 'Bind' to it again, or could I just 'listen' and 'accept' any subsequent connections by the remote TCP Client?
post edited by DougD - 2020/08/13 13:48:14