Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Socket connect error on DE2!

Altera_Forum
Honored Contributor II
1,085 Views

I modified the DE_WEB project ,and made a simple socket client to connect to the server on PC. 

The server on PC is developed on Visual C++,and it works well(can be connected by client on PC). 

But the client in this project on DE2 could not connect to the server,the function connect() returns errtimeout. but I can get reply from the DE2 board using ping command. 

what's wrong? 

 

here are some of code in client: 

 

static char* ip="192.168.0.139"; 

static int port=104; 

static SOCKET socketfd; 

static struct sockaddr_in local; 

void clienttask() 

{  

int flag; 

socketfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 

if(socketfd == INVALID_SOCKET) 

die_with_err("socket create fail"); 

local.sin_family = AF_INET; 

local.sin_port = htons(port); 

local.sin_addr.s_addr = inet_addr(ip); 

flag = connect(socketfd, (struct sockaddr*)&local, sizeof(local)); 

if(flag == SOCKET_ERROR)  

die_with_err("connect err"); 

 

 

}
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
386 Views

I check the errno,and find I/O Error 

who can tell me how to fix the problem?
0 Kudos
Reply