# mco_lews_check_connections
RT

### Prototype

        MCO_RET mco_lews_check_connections(timer_unit accept_timeout)

### Arguments

`accept_timeout`
Maximum time to wait (in milliseconds) for an incoming connection. If zero, the function returns immediately if no connection is pending.

### Description

> This function checks for new incoming client connections on the LEWS server socket and processes them if available. It blocks for up to `accept_timeout` milliseconds while waiting for a connection.

> It is typically called repeatedly in a server loop after mco_lews_start_listen() has been invoked.

>         MCO_RET mco_lews_start()
>         {
>             MCO_RET rc;

>             rc = mco_lews_start_listen();
>             if (MCO_S_OK != rc)
>                 return rc;

>             while (!stop_flag)
>             {
>                 rc = mco_lews_check_connections(LEWS_ACCEPT_TIMEOUT);
>                 /* Non-fatal or expected return codes are ignored */
>                 if ((rc != MCO_E_LEWS_TIMEOUT) &&
>                     (rc != MCO_S_OK) &&
>                     (rc != MCO_E_NW_ACCEPT))
>                     return rc;
>             }
>             return MCO_S_OK;
>         }

### Return Codes

`MCO_S_OK`
A connection was successfully accepted and processed.
`MCO_E_LEWS_TIMEOUT`
No connection arrived within the specified timeout period.
`MCO_E_NW_ACCEPT`
An accepted connection could not be fully initialized (e.g., due to resource limits).
Other error codes
Indicate a system or internal error (e.g., socket failure). These should be treated as fatal.

### Files

Header file:
mcoewslite.h
Source file:
mcoewslite.c
Library:
mcoewslite.a