Ejemplo n.º 1
0
U8_T GUDPBC_NewConn(U32_T XDATA* pip, U16_T remotePort, U8_T socket)
{
	U8_T	i;
	
	for(i = 0; i < GUDPBC_MAX_CONNS; i++)
	{		
		if(gudpbc_Conns[i].State == GUDPBC_STATE_FREE)
		{		
		  gudpbc_Conns[i].State = GUDPBC_STATE_CONNECTED;
		  gudpbc_Conns[i].UdpSocket = socket;
			return i;
		}
// new connection
		udp_scan_count = 0;
		
	}
	if(i == GUDPBC_MAX_CONNS)
	{	 
		gudpbc_Conns[0].State = GUDPBC_STATE_FREE;
		TCPIP_UdpClose(gudpbc_Conns[0].UdpSocket);		

		gudpbc_Conns[0].State = GUDPBC_STATE_CONNECTED;
		gudpbc_Conns[0].UdpSocket = socket;
	
		return 0;
	}

	return GUDPBC_NO_NEW_CONN;



} /* End of GUDPBC_NewConn() */
Ejemplo n.º 2
0
/*
 * ----------------------------------------------------------------------------
 * Function Name: SNTPC_Stop
 * Purpose: 
 * Params:
 * Returns:
 * Note:
 * ----------------------------------------------------------------------------
 */
void SNTPC_Stop(void)
{
	if (sntpc_Conns.State != SNTP_STATE_INITIAL)
	{
		TCPIP_UdpClose(sntpc_Conns.UdpSocket);
		sntpc_Conns.State = SNTP_STATE_INITIAL;
	}

} /* End of SNTPC_Stop() */
Ejemplo n.º 3
0
/*
 * ----------------------------------------------------------------------------
 * Function Name: SNTPC_Event
 * Purpose: 
 * Params:
 * Returns:
 * Note:
 * ----------------------------------------------------------------------------
 */
void SNTPC_Event(U8_T id, U8_T event)
{
	if (id != 0)
		return;

	if (event == TCPIP_CONNECT_CANCEL)
	{
		TCPIP_UdpClose(sntpc_Conns.UdpSocket);
		sntpc_Conns.State = SNTP_STATE_INITIAL;
	}

} /* End of SNTPC_Event() */