コード例 #1
0
TCP_SOCKET XivelyConn(char* ServerName, char* ServerPort)
{
	int j;
	TCP_SOCKET   MySocket = INVALID_SOCKET;
	#if defined(STACK_USE_UART)
	UARTWrite(1,"Connecting to Xively...\r\n");
	#endif
	MySocket = TCPClientOpen(ServerName, ServerPort);
	
	#if defined(STACK_USE_UART)
	if(MySocket == INVALID_SOCKET) 
	{
		UARTWrite(1,"INVALID_SOCKET\r\n");
	}
	UARTWrite(1,"Checking connection.\r\n");
	#endif
	// Make sure it connects
	j = 10;
	while (j>0 && !TCPisConn(MySocket))
	{
		//vTaskDelay(xDelay(500));
		vTaskDelay(500);
		j--;
		//sprintf(j, "%d\r\n", j+1);
	}
	if(j==0) 
	{
		#if defined(STACK_USE_UART)
		UARTWrite(1,"Connection failed.\r\n");
		#endif
		// Close the socket so it can be used by other modules
		TCPClientClose(MySocket);
		MySocket = INVALID_SOCKET;
		// We are in an error condition, so light up the Flyport led
	}
	return MySocket;
}
コード例 #2
0
static void disconnect()
{
	TCPClientClose(socket);
}
コード例 #3
0
ファイル: HTTPlib.c プロジェクト: OpenPicus/lib_fota_gprs_pro
/**
 * Closes connection to HTTP host
 * \param sock TCP_SOCKET to use
 * \return None
 */
void HTTPClose(TCP_SOCKET* sock)
{
	return TCPClientClose(sock);
}