From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10950 invoked by alias); 26 Dec 2001 13:26:26 -0000 Mailing-List: contact ecos-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@sources.redhat.com Received: (qmail 10912 invoked from network); 26 Dec 2001 13:26:25 -0000 Received: from unknown (HELO relay04.valueweb.net) (216.219.253.238) by sources.redhat.com with SMTP; 26 Dec 2001 13:26:25 -0000 Received: from thor.valueweb.net ([216.219.254.23]:56071 "EHLO thor.valueweb.net") by relay04.valueweb.net with ESMTP id ; Wed, 26 Dec 2001 08:26:20 -0500 Received: from [203.199.236.145] ([203.199.236.145]:18699 "HELO e600022") by thor.valueweb.net with SMTP id ; Wed, 26 Dec 2001 08:26:17 -0500 Reply-To: From: "Raman Sivam" To: Date: Wed, 26 Dec 2001 05:26:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Subject: [ECOS] TCP/IP problem X-SW-Source: 2001-12/txt/msg00366.txt.bz2 Dear Sir, We have written a small TCP client program which connects to a TCP server on Port 7734 .The hardware platform is EDB7212 . The Error message in connect system call is "Message Too long".The Progam that we tried is : #include #include #include #include #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL static char stack[2][STACK_SIZE]; static cyg_thread thread1,thread2; static cyg_handle_t t1,t2; struct sockaddr_in local,cli; int ser; void server(struct bootp *bp) { int c,i,*l,n,pp; char chdata='*'; if((ser=socket(AF_INET,SOCK_STREAM,0))<0) { perror("\nSERVER : socket"); exit(1); } printf("\nSERVER Socket Created"); cyg_thread_delay(50); memset(&local, 0, sizeof(local)); local.sin_family=AF_INET; local.sin_port=ntohs(7734); local.sin_addr.s_addr=INADDR_ANY; cli.sin_family=AF_INET; cli.sin_port=htons(7734); cli.sin_addr.s_addr=INADDR_ANY; diag_printf("Trying to bind..."); if(bind(ser,(struct sockaddr *) &local,sizeof(local))<0) { perror("\nSERVER : bind"); exit(1); } diag_printf("done\n"); diag_printf("Trying to listen..."); listen(ser,5); diag_printf("done\n"); while(1) { diag_printf("\nBefore accept..."); pp=sizeof(cli); c=accept(ser, (struct sockaddr *)&cli,&pp); if(c==-1) { perror("\nSERVER : accept"); exit(1); } diag_printf("done. \n Accept Sucessful"); diag_printf("Trying to read from the server..."); if(n=read(c,&chdata,1)<0) { perror("\nSERVER : read failed!!!"); exit(1); } diag_printf("\nCLIENT SENT %c",chdata); /***********************/ chdata = '@'; diag_printf("Trying to send @..."); if(write(c,&chdata,1)<0) { perror("\nSERVER : write failed"); exit(1); } diag_printf("done\nSERVER WROTE TO CLIENT"); close(c); /***********************/ } close(ser); } void client(struct bootp *bp) { int c; int i,s,l; char chd = '$'; struct sockaddr_in toCon; s=socket(AF_INET,SOCK_STREAM,0); if(s<0) { perror("\nCLIENT : socket"); exit(1); } printf("\nClinet Socket created"); cyg_thread_delay(50); toCon.sin_family=AF_INET; toCon.sin_addr = bp->bp_yiaddr; toCon.sin_port=htons(7734); l=sizeof(toCon); diag_printf("Trying to connect to the server..."); c=connect(s,(struct sockaddr*) &toCon,sizeof(toCon)); if(c<0) { perror("\nCLIENT : connect"); diag_printf("The Error number: %d", errno); exit(1); } diag_printf("done."); diag_printf("Trying to write a char to the server..."); l=sizeof(local); if(write(c,&chd,1)<0) { perror("\nSERVER : write failed"); exit(1); } diag_printf("done\nWROTE TO SERVER"); diag_printf("Trying to read a byte from the server..."); if(read(c,&i,1)<0) { perror("\nSERVER : read failed"); exit(1); } diag_printf("done\nSERVER WROTE : %d",i); diag_printf("\nCLIENT SAYS BYE"); close(c); } void net_test(cyg_addrword_t param) { if (eth0_up) { server(ð0_bootp_data); } } void net_test1(cyg_addrword_t param) { if (eth0_up) { client(ð0_bootp_data); } } void cyg_start(void) { init_all_network_interfaces(); cyg_thread_create(4,net_test,0,"Server",&stack[0],STACK_SIZE,&t1,&thread1); cyg_thread_create(5,net_test1,0,"Client",&stack[1],STACK_SIZE,&t2,&thread2); cyg_thread_resume(t1); cyg_thread_resume(t2); cyg_scheduler_start(); }