Code: Select all
while ( 1 )
{
DestIP = AsciiToIp( "192.168.42.87" );
DestPort = TCP_PORT; // #define TCP_PORT 23334 is above
iprintf( "Attempting to send to port\r\n");
if (tcp.Connect(DestIP, DestPort, 40))
{
iprintf( "Connection Succeeded. \r\n");
if (tcp.Connected())
{
iprintf( "Sending data to socket\r\n");
tcp.Printf("This message is from the TCP Client<EOF>" );
}
else
iprintf( "Socket not open\r\n" );
}
else
{
iprintf( "*** Connection Failed. \r\n");
}
if (tcp.Connected())
{
tcp.Close();
iprintf( "Closing socket \r\n");
}
else
iprintf( "Socket not connected\r\n" );
OSTimeDly(20);
}
Code: Select all
Attempting to send to port
Connection Succeeded.
Sending data to socket
Closing socket
If I run this without the server process running on a nearby networked PC I get one of these and nothing else (unexpected):
Code: Select all
Attempting to send to port
Code: Select all
*** Connection Failed.
Dave