Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Originating-IP: [195.92.67.76] X-Originating-Email: [graham_walsh50 AT hotmail DOT com] X-Sender: graham_walsh50 AT hotmail DOT com From: "Graham Walsh" To: cygwin AT cygwin DOT com Subject: sys/types.h fails to compile under g++ Date: Sat, 31 Jan 2004 09:52:15 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 31 Jan 2004 14:52:16.0001 (UTC) FILETIME=[D147F710:01C3E809] Hiya, first time using cygwin.... I have a linker error when compiling a stock socket app. All I use is standard calls to socket, bind etc. etc. All the symbols usually located in libsocket.so on unix are missing, i.e. bind, socket, etc. etc. I am at a loss as to what to link against. If anybody knows the compilation and link options I need it would help me out completely. I am assuming that the standard cygwin release provides all the libs I need to do this type of unix coding on my humble XP box. If I've missed anything, please let me know. I am using GCC v3.2 on an XP machine with the latest cygwin installation. my goal here is simply to write unix style code with gcc on my xp box. Cheers, GrahamO #include #include #include #include #include #include #include #include #include #define PORT 3550 /* Port that will be opened */ #define BACKLOG 2 /* Number of allowed connections */ extern "C" int close(int); extern "C" void bzero(void *, size_t); using namespace std; main() { int fd, fd2; /* file descriptors */ struct sockaddr_in server; /* server's address information */ struct sockaddr_in client; /* client's address information */ int sin_size; if ((fd=socket(AF_INET, SOCK_STREAM, 0)) == -1 ) { /* calls socket() */ printf("socket() error\n"); exit(-1); } server.sin_family = AF_INET; server.sin_port = htons(PORT); /* Remember htons() from "Conversions" section? =) */ server.sin_addr.s_addr = INADDR_ANY; /* INADDR_ANY puts your IP address automatically */ // bzero(&(server.sin_zero),8); /* zero the rest of the structure */ // void *memset (void *ptr, int val, size_t len); memset(&(server.sin_zero), 0, 8); if(bind(fd,(struct sockaddr*)&server,sizeof(struct sockaddr))==-1){ /* calls bind() */ printf("bind() error\n"); exit(-1); } if(listen(fd,BACKLOG) == -1){ /* calls listen() */ printf("listen() error\n"); exit(-1); } while(1){ sin_size=sizeof(struct sockaddr_in); if ((fd2 = accept(fd,(struct sockaddr *)&client,&sin_size))==-1){ /* calls accept() */ printf("accept() error\n"); exit(-1); } printf("You got a connection from %s\n",inet_ntoa(client.sin_addr) ); /* prints client's IP */ send(fd2,"Welcome to my server.\n",22,0); /* send to the client welcome message */ close(fd2); /* close fd2 */ } } /* <---- SOURCE CODE ENDS HERE ----> */ _________________________________________________________________ Scope out the new MSN Plus Internet Software — optimizes dial-up to the max! http://join.msn.com/?pgmarket=en-us&page=byoa/plus&ST=1 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/