Releasing a UDP socket

USOCKET fnReleaseUDP_socket(USOCKET cSocketHandle);

cSocketHandle is the socket which is to be released and returned to the UDP socket pool.

fnReleaseUDP_socket is called to release a no longer required socket.

The function returns the socket number of the successfully released socket or else the following error:

  • INVALID_SOCKET_HANDLE {the specified socket was invalid and so nothing was performed}


  • If the returned value equals the socket reference the socket was sucsessfully returned to the UDP socket pool and can thus be reused later for other UDP use. The socket no longer exists and so should not be reused without first obtaining it again by calling fnGetUDP_socket();

    Project options

    There are no project options affecting this function.

    Examples

    static USOCKET MyUDP_Socket = -1;
    
    if (!((MyUDP_Socket = fnGetUDP_socket(TOS_MINIMISE_DELAY, fnUDPListner, (0))) < 0)) {
        if (MyUDP_Socket == fnReleaseUDP_socket(MyUDP_Socket)) { // immediately release the socket
            MyUDP_Socket = -1;          // mark that the socket is free again
        }
    }

    Related functions

    fnGetUDP_socket(); fnBindSocket(); fnHandleUDP(); fnSendUDP(); fnReportUDP();


    For more details about the use of UDP in the µTasker project, the following forum thread is recommended about the udp use!



    Please use the µTasker forum to ask specific questions.