Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Socket connect error on DE2!

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");

}

}

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I check the errno,and find I/O Error

    who can tell me how to fix the problem?