From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10815 invoked by alias); 17 Jun 2005 14:11:08 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 10785 invoked by uid 22791); 17 Jun 2005 14:11:02 -0000 Received: from mail.esiee.fr (HELO mail.esiee.fr) (147.215.1.3) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 17 Jun 2005 14:11:02 +0000 Received: from mail.esiee.fr (localhost.esiee.fr [127.0.0.1]) by mail.esiee.fr (Postfix) with SMTP id 8A2D3365917 for ; Fri, 17 Jun 2005 16:10:43 +0200 (CEST) Received: from esiee.fr (localhost.esiee.fr [127.0.0.1]) by mail.esiee.fr (Postfix) with ESMTP id E9E37365910 for ; Fri, 17 Jun 2005 16:10:42 +0200 (CEST) Content-Type: text/plain; charset=iso-8859-1 User-Agent: IMHO/0.99 (Webmail for Roxen) Date: Fri, 17 Jun 2005 14:11:00 -0000 In-Reply-To: <1119016906.32044.ezmlm@ecos.sourceware.org> MIME-Version: 1.0 To: ecos-discuss@sources.redhat.com From: Thierry =?iso-8859-1?q?Br=E9mard?= Message-Id: <20050617141042.E9E37365910@mail.esiee.fr> Content-Transfer-Encoding: quoted-printable Subject: [ECOS] TCP socket problem : connect and bind X-SW-Source: 2005-06/txt/msg00142.txt.bz2 Hello, I have the code folowing , it works fine under a cygwin environement, it compiles fine with the ecos tools and I load it fine on my viper card. after a 'load -v -m ymodem' I run: 'go' and I have an error of connect() and of bind(). Furthermore I can ping the viper card thanks to my computer, but the command 'ping -n 3 -h 1.1.1.2' doesn't succeed on the redboot environement (where 1.1.1.2 is the ip of my computer), my computer is linked with a ethernet cable to the card directly. =3D> is there some functions to call before using the network ? in my repository I have an ecos environnement build arround the 'net' package. ** #include #include #include #include #define SOCKET_ERROR -1 int OpenPort(int port) { struct sockaddr_in sin; int sock; unsigned char val=3D1; if((sock=3Dsocket(AF_INET,SOCK_STREAM,0)) =3D=3D SOCKET_ERROR) return 0; sin.sin_port=3Dhtons((short)port); sin.sin_addr.s_addr=3D0; sin.sin_family=3DAF_INET; //Allow the socket to be bound to an address which is already in use //=20=20=20 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(val))=3D=3DSOCKET_E RROR) return 0; // (By default, a socket cannot be bound to a local address which is already in use.) if(bind(sock,(struct sockaddr *)&sin,sizeof(sin))=3D=3DSOCKET_ERROR) return 0; if(listen(sock,SOMAXCONN)=3D=3DSOCKET_ERROR) return 0; return sock; } int connecta(short port) { struct sockaddr_in sin; int sock; if((sock=3Dsocket(AF_INET,SOCK_STREAM,0)) =3D=3D SOCKET_ERROR) return 0; sin.sin_port=3Dhtons((short)port); sin.sin_addr.s_addr =3D inet_addr("147.215.40.139"); sin.sin_family=3DAF_INET; //Allow the socket to be bound to an address which is already in use //=20=20=20 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(val))=3D=3DSOCKET_E RROR) return 0; // (By default, a socket cannot be bound to a local address which is already in use.) // if(bind(sock,(struct sockaddr *)&sin,sizeof(sin))=3D=3DSOCKET_ERROR) return 0; connect(sock, (struct sockaddr *)&sin, sizeof(sin)); //if(listen(sock,SOMAXCONN)=3D=3DSOCKET_ERROR) return 0; return sock; } int main() { int sock; int sock_client; =20=20=20=20 connecta(90); =20=20=20=20 sock =3D OpenPort(90); sock_client =3D accept(sock, NULL, 0); printf("client connected"); return 0; =20=20=20=20 =20=20=20=20 =20=20=20=20 } **eof Thank you=20 Thierry -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss