Пример #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
/**
 * Closes connection to HTTP host
 * \param sock TCP_SOCKET to use
 * \return None
 */
void HTTPClose(TCP_SOCKET* sock)
{
	return TCPClientClose(sock);
}