My RCM4010 working as a client to send message to a simple server written with Delphi. The server displays what is sent to it.
My network is a simple one with only one router. RCM4010 and my PC are hooked up to this router.
After message is sent, it takes about 14 sec to reach the server and be displaed there. I display the status of my RCM4010 in the stdio. It is found that the messages are sent right away and the socket closed properly after sending all the messages. My server can then display the message 14 seconds later.
I run another client (written by Delphi as well) in another PC. Its message is displayed immediately on the server.
I pinged my RCM4010 and the RTT is 2 mS.
My code is listed below. Can someome let me know what mistake I made?
#define TCPCONFIG 1
#use “dcrtcp.lib”
/*
- Remote computer to contact:
*/
#define DEST “www.rabbit.com”
#define PORT 50
////////////////////////////////////////////////////////////////////////
void main()
{
char buffer[100]; /* Currently (DC 7.30), printf() has max 127 bytes it can output. */
int bytes_read, aa, ab, i;
longword destIP;
tcp_Socket socket;
unsigned long int T1;
destIP = 3232235878; //192.168.1.102
// Start network and wait for interface to come up (or error exit).
sock_init_or_exit(1);
tcp_open(&socket,0,destIP,PORT,NULL);
printf("Waiting for connection...
");
while(!sock_established(&socket) && sock_bytesready(&socket)==-1) {
tcp_tick(NULL);
}
printf("Connection established, sending a message...
");
for (i=0; i<=99; ++i) {
aa = sock_write(&socket,"Frank ",6);
printf("Sock awrite = %d; i=%d
", aa, i);
}
sock_close(&socket);
printf("waiting for socket to close!
");
ab = 0;
do{
aa = tcp_tick(NULL);
ab=1;
if(ab=0) printf("Still waiting!!
");
}
while(aa==0);
printf("
Connection closed…
");
}
:o