This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
about socket program
- From: zhulin at digitalchina dot com
- To: ecos-discuss at sources dot redhat dot com
- Date: Sun, 29 Sep 2002 11:40:18 +0800
- Subject: [ECOS] about socket program
hi.
i have writed the socket code,as follawing:
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
int port =6789;
void main(){
int socket_descriptor;int iter =0;
int process;
char buf[80];
struct sockaddr_in address;
socket_descriptor=socket(AF_INET,SOCK_DGRAM,0);
memset(&address,0,sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr("127.0.0.1");
address.sin_port = htons(port);
process =1;
do{
sprintf(buf,"data packet with ID %d\n",iter);
if(iter>20){
sprintf(buf,"stop\n");
process = 0;
}
sendto(socket_descriptor,buf,sizeof(buf),0,(struct
sockaddr *)
&address,sizeof(address));
iter++;
}while(process);
}
and then, i used the xscale-elf-gcc to compile it:
xscale-elf-gcc -IBASE/install/include -LBASE/install/lib -Ttarget.ld
-nostdlib udpserver.c
but,it return me error:
install/include/sys/socket.h:194: parse error before "u_inet8_t"
install/include/sys/socket.h:197: parse error before "}" token
...
i dont know how to resovle it.
help me,pls.
thank you!
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss