Hello:
I am new to wifi. I am using RCMN4400 as a client trying to make connection to my PC server.
Using the sample code pingLED I can ping my PC and using the sample ECHO.C (modified to work on wifi) I can got echo from my PC as well.
I made similar changes (on IPs) to sample code TCP_SIMPLE.c but I couldn’t make connection to my PC. I would appreciate any help. Please find my code listed below. Can someone give me a simple code? Thanks
/********************************************************************
tcp_client_simple.c
Z-World, 2005
This program is a simple TCP client. It opens a single TCP
socket to a remote host, and then sends 10 “Hello” messages
on that socket. After the last message is sent, the socket
is closed and the program exits.
********************************************************************/
#define TCPCONFIG 1
#memmap xmem
#define _PRIMARY_STATIC_IP “192.168.1.201”
#define LOCAL_NETMASK “255.255.255.0”
#define LOCAL_GATEWAY “192.168.1.2”
#define MY_NAMESERVER “192.168.1.3”
#define PORT 51
#define _WIFI_SSID “NetPortal”
#define _WIFI_MODE WIFICONF_INFRASTRUCT
#define _WIFI_REGION_REQ _AMERICAS_REGION
#define WIFI_WEP_FLAG WIFICONF_WEP_DISABLE
#define DCRTCP_DEBUG
#define DCRTCP_VERBOSE
#use RCM44xxW.lib
#use “dcrtcp.lib”
tcp_Socket sock;
void main(void) {
auto int count;
count = 0;
sock_init();
tcp_open(&sock, 0, inet_addr("192.168.1.154"), 51, NULL);
while (!sock_established(&sock)) {
tcp_tick(NULL);
}
while (count < 10 && sock_established(&sock)) {
tcp_tick(NULL);
costate {
sock_write(&sock, "Hello
", strlen("Hello
"));
count++;
waitfor(IntervalSec(1));
}
}
sock_close(&sock);
while (sock_alive(&sock)) {
tcp_tick(NULL);
}
printf("Program complete!
");
}
Regards
Frank