/* Wait for a client connection to the server.  */
WIFI_Status_t WIFI_WaitServerConnection(int socket, uint32_t Timeout, uint8_t *RemoteIp, uint16_t *RemotePort)
/* Wait for a client connection to the server.  */
WIFI_Status_t WIFI_WaitServerConnection(int socket, uint32_t Timeout, uint8_t *RemoteIp, uint16_t *RemotePort)
{
  ES_WIFI_Conn_t conn;
  ES_WIFI_Status_t ret;
  conn.Number = socket;
  ret = ES_WIFI_WaitServerConnection(&EsWifiObj,Timeout,&conn);
  if (ES_WIFI_STATUS_OK == ret)
  {
    if (RemotePort) *RemotePort=conn.RemotePort;
    if (RemoteIp)
    {
      memcpy(RemoteIp,conn.RemoteIP,sizeof(conn.RemoteIP));
    }
    return  WIFI_STATUS_OK;
  }
  if (ES_WIFI_STATUS_TIMEOUT ==ret)
  {
    if (RemotePort) *RemotePort=0;
    if (RemoteIp)
    {
      memset(RemoteIp,0,sizeof(conn.RemoteIP));
    }
    return  WIFI_STATUS_TIMEOUT;
  }
  return WIFI_STATUS_ERROR;
}