From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28267 invoked by alias); 20 Jun 2005 10:20:25 -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 28259 invoked by uid 22791); 20 Jun 2005 10:20:18 -0000 Received: from mail.esiee.fr (HELO mail.esiee.fr) (147.215.1.3) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 20 Jun 2005 10:20:18 +0000 Received: from mail.esiee.fr (localhost.esiee.fr [127.0.0.1]) by mail.esiee.fr (Postfix) with SMTP id 9C595365927 for ; Mon, 20 Jun 2005 12:20:16 +0200 (CEST) Received: from esiee.fr (localhost.esiee.fr [127.0.0.1]) by mail.esiee.fr (Postfix) with ESMTP id 2E3A8365926 for ; Mon, 20 Jun 2005 12:20:15 +0200 (CEST) Content-Type: text/plain; charset=iso-8859-1 User-Agent: IMHO/0.99 (Webmail for Roxen) Date: Mon, 20 Jun 2005 10:20:00 -0000 MIME-Version: 1.0 To: ecos-discuss@sources.redhat.com From: Thierry =?iso-8859-1?q?Br=E9mard?= Message-Id: <20050620102015.2E3A8365926@mail.esiee.fr> Content-Transfer-Encoding: quoted-printable Subject: [ECOS] TCP: accept fails whereas connect succesful X-SW-Source: 2005-06/txt/msg00168.txt.bz2 Hello, I am still on my TCP Server, I managed to specify a static IP address and now I am able to connect from my arcom viper card to my PC and send to my pc data via TCP sockets. However my final issue is to build a server on my viper card. My function OpenPort return with 1 (succesful) and when I attempt to connect (whith the correct ip and correct port) with a telnet , I can see SYN request from my PC without any ack from the viper. Furthermore, it doesn't reply to arp request (ie for the moment I have to set a arp -s ip mac to be able to send packets to the viper .. but the viper announce itself (once)just after the go command ) I built my project with the eCos configuration Tool, selected the 'net' package, checked and filled the 'address setups for eth0' and unchecked the DNS support (because only work whit ip addresses). Here is the output of redBoot, lauching my eCos program ---------------------------------------------------------------- RedBoot> RedBoot> go [cyg_net_init] Init: mbinit(0x00000000) [cyg_net_init] Init: cyg_net_init_devs(0x00000000) Init device 'lan91cxx_eth0' [cyg_net_init] Init: loopattach(0x00000000) [cyg_net_init] Init: ifinit(0x00000000) [cyg_net_init] Init: domaininit(0x00000000) [cyg_net_init] Init: cyg_net_add_domain(0x0043d774) New domain internet at 0x00000000 [cyg_net_init] Init: cyg_net_add_domain(0x0043d1fc) New domain route at 0x00000000 [cyg_net_init] Init: call_route_init(0x00000000) [cyg_net_init] Done BOOTP[eth0] op: REPLY htype: Ethernet hlen: 6 hops: 0 xid: 0x0 secs: 0 flags: 0x0 hw_addr: 00:80:66:10:14:ee client IP: 147.215.40.77 my IP: 147.215.40.77 server IP: 147.215.40.2 gateway IP: 147.215.40.1 options: subnet mask: 255.255.255.0 IP broadcast: 147.215.40.255 gateway: 147.215.40.1 [eth_drv_ioctl] Warning: Driver can't set multi-cast mode [eth_drv_ioctl] Warning: Driver can't set multi-cast mode [eth_drv_ioctl] Warning: Driver can't set multi-cast mode Server Redboot ! Opening port 105..ok ---------------------------------------------------------------- is the fact that I have the message: [eth_drv_ioctl] Warning: Driver can't set multi-cast mode is normal ? the code blocks at "Opening port 105..ok" :at the call of accept(), but I doesn't handle any connections. nor reply to any arp reply .. WHY ? =20 Here is the source code: ---------------------------------------------------------------- #include #include #include #include #define SOCKET_ERROR -1 #define DESIRED_BACKGROUND_LOAD 50 int OpenPort(unsigned short port) { struct sockaddr_in sin; int sock; if((sock =3D socket(AF_INET, SOCK_STREAM, 0))=3D=3D SOCKET_ERROR) { printf("error in OpenPort, socket()"); return 0; } sin.sin_port =3D htons(port); sin.sin_addr.s_addr =3D 0; // sin.sin_addr.s_addr =3D INADDR_ANY; sin.sin_family =3D AF_INET; sin.sin_len =3D sizeof(sin); =20=20=20=20=20=20=20=20 if(SOCKET_ERROR =3D=3D bind(sock, (struct sockaddr *)&sin, sizeof(struct sockaddr_in) )) { printf("error in OpenPort, bind()"); return 0; } if(SOCKET_ERROR =3D=3D listen(sock, SOMAXCONN)) { printf("error in OpenPort, listen()"); return 0; } return sock; } int Connexion(unsigned short port) { struct sockaddr_in sin; int sock; if((sock =3D socket(AF_INET, SOCK_STREAM, 0))=3D=3D SOCKET_ERROR) { printf("error in OpenPort, socket()\n"); return 0; } sin.sin_port =3D htons(port); sin.sin_addr.s_addr =3D inet_addr("147.215.40.139"); sin.sin_family =3D AF_INET; =20=20 if(SOCKET_ERROR =3D=3D connect(sock, (struct sockaddr *)&sin, sizeof(struct sockaddr_in) )) { printf("error in Connexion, connect()\n"); return 0; } return sock; } // envoi les donn=E9es point=E9es par data taille =3D len // tout est envoy=E9 grace =E0 un appel =E0 recv dans le while // retourne le nombre d'octets envoy=E9s int SendData(int sock, char *data, int len) { int total =3D 0; int ret; =20=20=20=20 while((ret =3D send(sock, data, len, 0))>0) // envoi les donn=E9es { total +=3D ret; // octets envoy=E9s au total data +=3D ret; // pointe plus loin sur les donn=E9es non envoy=E9es len -=3D ret; // la taille restante diminue } =20=20=20=20 return total; // nombre d'octets envoy=E9s } // envoie la chaine de caract=E8re ascii, termin=E9e par un 0. // retourne le nombre d'octets envoy=E9s (n'envoie pas le 0) int SendString(int sock, char *str) { return SendData(sock, str, strlen(str)); } // recoit des donn=E9es, les stocke dans buffer // la r=E9ception s'ach=E8ve oubien quand len octets ont =E9t=E9 recus // ou bien quand \n est recu. // les caract=E8res \r et \n sont enlev=E9s de la fin du buffer avant de retourner // le nombre de caract=E8res mis dans buffer est retourn=E9. int RecvLine(int sock, char *buffer, int len) { char c; int total =3D 0; int ret; =20=20=20=20 memset(buffer, 0 , len); =20=20=20=20 while( (total0) ) { memcpy(&buffer[total], &c, ret ); // buffer[total] =3D c; total +=3D ret; // total++; if(buffer[total-1] =3D=3D'\n') break ; // sortie de la boucle si retour chariot recu. =20=20=20=20 } =20=20=20=20 len =3D strlen(buffer); while((buffer[len-1] =3D=3D'\n') || (buffer[len-1] =3D=3D'\r')) { buffer[len-1] =3D 0; // =E9crase \n ou \r par caract=E8re de fin de chaine len--; if(!len) // si taille nulle break; // termine la boucle } =20=20=20=20 return len; =20=20=20=20 } //void cyg_user_start(void) int main(void) { //int i; int sock, client; char buffer[1024]; init_all_network_interfaces(); // calibrate_load(DESIRED_BACKGROUND_LOAD); printf("Server Redboot !\n"); =20=20=20=20 /* if(sock =3D Connexion(90)) { //(commented but this piece works fine) printf("Connected ... "); SendString(sock, "Hello Server, I am the Viper !!\r\n"); SendString(sock, "quit\r\n"); close(sock); printf("Disconnected!\r\n"); =20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20 }*/ =20=20=20=20=20=20=20=20 =20=20=20=20=20=20=20=20 printf("Opening port 105.."); if(!(sock =3D OpenPort(105))) { printf("error opening port !\n"); return 0; } printf("ok\n"); =20=20=20=20 =20=20=20=20 if(SOCKET_ERROR =3D=3D (client =3D accept(sock, NULL, 0))) { printf("error of accept!"); return 0; } printf("Client connected!"); strcpy(buffer, "Hello you are on the Viper Server!\r\n"); SendString(client, buffer); while(strncmp(buffer, "quit", 3)) { RecvLine(client, buffer, 1024); printf("client sent: %s", buffer); SendString(client, "220 ok for"); SendString(client, buffer); SendString(client, "\r\n"); }=20=20=20=20 =20=20=20=20 close(sock); close(client); puts("Server finished"); return 0; =20=20 } ---------------------------------------------------------------- the connexion works fine but the open port blocks at accept and doesn't seem to handle client connections. Thank you 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