AzureMXChip/MXCHIPAZ3166/core/lib/netxduo/addons/web/nx_tcpserver.c
UINT _nx_tcpserver_start(NX_TCPSERVER *server_ptr, UINT port, UINT listen_queue_size)
{
UINT            status;
NX_TCP_SESSION *session_ptr;

    /* Check whether listen is done. */
    if(server_ptr -> nx_tcpserver_listen_port)
        return NX_TCPSERVER_FAIL;

    /* Get a socket to listen. */
    status = _nx_tcpserver_session_allocate(server_ptr, &session_ptr);
    if(status)
        return status;

    /* Listen on port. */
    status = nx_tcp_server_socket_listen(server_ptr -> nx_tcpserver_ip, port, &session_ptr -> nx_tcp_session_socket, listen_queue_size, _nx_tcpserver_connect_present);
    if(status)
        return status;

    /* Store socket and port. */
    server_ptr -> nx_tcpserver_listen_session = session_ptr;
    server_ptr -> nx_tcpserver_listen_port = port;

    /* Activate timer. */
    tx_timer_activate(&server_ptr -> nx_tcpserver_timer);

    /* Start thread. */
    tx_thread_resume(&server_ptr -> nx_tcpserver_thread);

    return NX_SUCCESS;
}
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _nx_tcpserver_start                                  PORTABLE C     */
/*                                                           6.1          */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Yuxin Zhou, Microsoft Corporation                                   */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function is called by an application to start a socket server  */
/*    that was previously created and configured. This routine starts the */
/*    internal server thread and timer.                                   */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    server_ptr                            Pointer to server structure   */
/*    port                                  Port for server to listen on  */
/*    listen_queue_size                     Maximum number of TCP         */
/*                                            connections queued          */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    status                                Completion status             */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    _nx_tcpserver_session_allocate        Allocate socket for listening */
/*    nx_tcp_server_socket_listen           Listen on free TCP socket     */
/*    tx_timer_activate                     Start timeout timer           */
/*    tx_thread_resume                      Start server thread           */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*   Application code                                                     */
/*                                                                        */
/*  RELEASE HISTORY                                                       */
/*                                                                        */
/*    DATE              NAME                      DESCRIPTION             */
/*                                                                        */
/*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
/*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
/*                                            resulting in version 6.1    */
/*                                                                        */
/**************************************************************************/
FUNCTION                                               RELEASE

_nx_tcpserver_start                                  PORTABLE C
6.1
AUTHOR

Yuxin Zhou, Microsoft Corporation

DESCRIPTION

This function is called by an application to start a socket server
that was previously created and configured. This routine starts the
internal server thread and timer.

INPUT

server_ptr                            Pointer to server structure
port                                  Port for server to listen on
listen_queue_size                     Maximum number of TCP
connections queued

OUTPUT

status                                Completion status

CALLS

_nx_tcpserver_session_allocate        Allocate socket for listening
nx_tcp_server_socket_listen           Listen on free TCP socket
tx_timer_activate                     Start timeout timer
tx_thread_resume                      Start server thread

CALLED BY

Application code

RELEASE HISTORY

DATE              NAME                      DESCRIPTION

05-19-2020     Yuxin Zhou               Initial Version 6.0
09-30-2020     Yuxin Zhou               Modified comment(s),
resulting in version 6.1
FUNCTION RELEASE _nx_tcpserver_start PORTABLE C 6 . 1 AUTHOR Yuxin Zhou Microsoft Corporation DESCRIPTION This function is called by an application to start a socket server that was previously created and configured . This routine starts the internal server thread and timer . INPUT server_ptr Pointer to server structure port Port for server to listen on listen_queue_size Maximum number of TCP connections queued OUTPUT status Completion status CALLS _nx_tcpserver_session_allocate Allocate socket for listening nx_tcp_server_socket_listen Listen on free TCP socket tx_timer_activate Start timeout timer tx_thread_resume Start server thread CALLED BY Application code RELEASE HISTORY DATE NAME DESCRIPTION 05 - 19 - 2020 Yuxin Zhou Initial Version 6 . 0 09 - 30 - 2020 Yuxin Zhou Modified comment ( s ) resulting in version 6 . 1
UINT _nx_tcpserver_start(NX_TCPSERVER *server_ptr, UINT port, UINT listen_queue_size)
{
UINT            status;
NX_TCP_SESSION *session_ptr;
    if(server_ptr -> nx_tcpserver_listen_port)
        return NX_TCPSERVER_FAIL;
    status = _nx_tcpserver_session_allocate(server_ptr, &session_ptr);
    if(status)
        return status;
    status = nx_tcp_server_socket_listen(server_ptr -> nx_tcpserver_ip, port, &session_ptr -> nx_tcp_session_socket, listen_queue_size, _nx_tcpserver_connect_present);
    if(status)
        return status;
    server_ptr -> nx_tcpserver_listen_session = session_ptr;
    server_ptr -> nx_tcpserver_listen_port = port;
    tx_timer_activate(&server_ptr -> nx_tcpserver_timer);
    tx_thread_resume(&server_ptr -> nx_tcpserver_thread);
    return NX_SUCCESS;
}
UINT _nx_tcpserver_start ( NX_TCPSERVER * server_ptr , UINT port , UINT listen_queue_size ) { UINT status ; NX_TCP_SESSION * session_ptr ; if ( server_ptr -> nx_tcpserver_listen_port ) return NX_TCPSERVER_FAIL ; status = _nx_tcpserver_session_allocate ( server_ptr , & session_ptr ) ; if ( status ) return status ; status = nx_tcp_server_socket_listen ( server_ptr -> nx_tcpserver_ip , port , & session_ptr -> nx_tcp_session_socket , listen_queue_size , _nx_tcpserver_connect_present ) ; if ( status ) return status ; server_ptr -> nx_tcpserver_listen_session = session_ptr ; server_ptr -> nx_tcpserver_listen_port = port ; tx_timer_activate ( & server_ptr -> nx_tcpserver_timer ) ; tx_thread_resume ( & server_ptr -> nx_tcpserver_thread ) ; return NX_SUCCESS ; }
FUNCTION                                               RELEASE
FUNCTION RELEASE
/* Check whether listen is done. */ /* Get a socket to listen. */ /* Listen on port. */ /* Store socket and port. */ /* Activate timer. */ /* Start thread. */