Hi,
I am trying to run tcp client to connect to server application, simply send and receive data.
I am getting error on connect, below is the detailed data of the system I am running and the error I am receiving.
I will provide the following data in this post in the following order:
1) Test that I made in order to verify my tcp server is OK
2) The components versions that I am running
3) My code
4) The output of the running
5) Additional two tests I performed and this is why I am suspecting I am not getting even IP
6) two updates with additional important data that I added
Test that I made in order to verify my tcp server is OK
Please note:
I tested my tcp server before running the program this way:
- Downloaded tcp server and tcp client programs to my pc
- verified my ip (using ipconfig on my windows computer) and running the server waiting on port 2222
- running the tcp client software to connect to my ip and port 2222
- connection success and i manage to transfer data between both.
Now I closed the tcp client program, restarted tcp server, verified my ip again and run my program I wrote, it fails.
The components versions that I am running
ccs: 5.4.0.00091
bios: 6_35_01_29
pspdrivers: 01_30_01
nsp: nsp_1_10_02_09
ndk: ndk_2_22_03_20
xdctools: 3_25_00_48
xgconf: I selected "global network settings", "http", "tcp", "ip" and enable IPv6. I also tried to activate the "dhcp client".
My code
Creating the task:
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.stackSize = 512*4;
taskParams.priority = 1;
taskParams.arg0 = NULL;
taskParams.arg1 = NULL;
task = Task_create(tcpTask,&taskParams, &eb);
The task:
Void tcpTask(UArg a0, UArg a1)
{
SOCKET s;
struct sockaddr_in sin1;
int i;
char *pBuf = 0;
struct timeval timeout;
Task_sleep(10000); //waiting 10 seconds, just in case for the test - so all ip setting will be ready... in next vers i will look for some event
// Allocate the file descriptor environment for this Task
if (!fdOpenSession( (HANDLE)Task_self() ))
return;
printf("\n== Start TCP Echo Client Test ==\n");
IPN IPAddr = inet_addr("192.168.14.197"); //the ip of my computer where I am running the tcp server program
// Create test socket
s = socket(AF_INET, SOCK_STREAMNC, IPPROTO_TCP);
if( s == INVALID_SOCKET )
{
printf("failed socket create (%d)\n",fdError());
goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_len = sizeof( sin1 );
sin1.sin_addr.s_addr = IPAddr;
sin1.sin_port = htons(2222); //the port my server is listening to
// Configure our Tx and Rx timeout to be 5 seconds
timeout.tv_sec = 5;
timeout.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
// Connect socket
if( connect( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
printf("failed connect (%d)\n",fdError());
goto leave;
}
The output of the running
Using default MAC address
Using MAC Address: 00-08-ee-03-14-99
enter main()
00000.000 MAC Address = 00-08-ee-03-14-99
00000.000 EMAC should be up and running
00000.000 EMAC has been started successfully
00000.000 Registeration of the EMAC Successful
Service Status: DHCPC : Enabled : : 000
Service Status: DHCPC : Enabled : Running : 000
Link Status: 100Mb/s Full Duplex on PHY 0
== Start TCP Echo Client Test ==
failed connect (6)
== End TCP Echo Client Test ==
Service Status: DHCPC : Enabled : Fault : 002
Additional two tests I performed and this is why I am suspecting I am not getting even IP
== Start TCP Echo Client Test ==
failed connect (65)
== End TCP Echo Client Test =
Second important update:
i openned my router statistics file, it seems that the device is detected and also the router gives an ip (when fixed ip, the router detects the Mac of the device and the ip I gave, when dhcp, the router shows the Mac and an ip that it gave to the device!)
-----