Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com> List-Archive: <http://sources.redhat.com/ml/cygwin/> List-Post: <mailto:cygwin AT cygwin DOT com> List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> 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-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Sat, 31 Jan 2004 14:37:12 -0500 (EST) From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu> Reply-To: cygwin AT cygwin DOT com To: Graham Walsh <graham_walsh50 AT hotmail DOT com> cc: cygwin AT cygwin DOT com Subject: Re: sys/types.h fails to compile under g++ In-Reply-To: <Law12-F68BdGrxSfQS8000270e7@hotmail.com> Message-ID: <Pine.GSO.4.56.0401311433190.20927@slinky.cs.nyu.edu> References: <Law12-F68BdGrxSfQS8000270e7 AT hotmail DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Note-from-DJ: This may be spam Graham, Please don't quote raw e-mail addresses in your replies. Let's not make the spam harvesters' lives any easier. FYI, the latest version of gcc for Cygwin is 3.3.1-3. Igor On Sat, 31 Jan 2004, Graham Walsh wrote: > thanks for that Larry. > > I'm going to install and download the latest g++ version (v3.2.3 apparently) > however I am not %100 confident that it will address the issue I'm > encountering. I'm running with g++ v3.2, I doubt this issue is addressed in > such a minor release. It seems that there's something fundamentally wrong > with one of the packages (cygwin or gnu). I cannot understand how such a > widely used compiler should fail to compile a simple file like <sys/types.h> > off the bat. > > I cannot say that with confidence until I download the latest gnu g++ > compiler release. PLEASE PLEASE PLEASE let this work otherwise I'm gonna > have to start programming using the MS socket interface API's which is what > I expressly set out to avoid. > > If anybody reads this and has a socket client/server demo with makefiles, > could they pass them on to me. If they could let me know the versions of g++ > and cygwin they're using to build, it would also help me eliminate > compiler/version dependencies. > > Cheers, I'll let you know how I fare. > > GrahamO > > > >From: Larry Hall <cygwin-lh<at>cygwin<dot>com> > >Reply-To: Cygwin List <cygwin<at>cygwin<dot>com> > >To: "Graham Walsh" <graham_walsh50<at>hotmail<dot>com>, cygwin<at>cygwin<dot>com > >Subject: Re: sys/types.h fails to compile under g++ > >Date: Sat, 31 Jan 2004 13:24:53 -0500 > > > >WFM with 'g++ -o sock sock.cpp'. > > > >Your gcc/g++ is out of date, though I doubt that's the main problem. See > ><http://cygwin.com/problems.html> if you need to post again for help on > >this issue. > > > >Thanks, > > > >Larry > > > > > >At 09:52 AM 1/31/2004, Graham Walsh you wrote: > > >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 <stdio.h> > > >#include <sys/types.h> > > >#include <sys/socket.h> > > >#include <netinet/in.h> > > >#include <netdb.h> > > >#include <unistd.h> > > >#include <string.h> > > >#include <arpa/inet.h> > > >#include <stdlib.h> > > >#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 ----> */ -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- 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/