From: bgmiller AT dccinc DOT com (Ben Miller) Subject: Re: compiling winsock apps 28 Oct 1997 20:24:30 -0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit To: newsham AT aloha DOT net Cc: gnu-win32 AT cygnus DOT com try renaming the file to winsock.cpp and then compiling it. It will generate these errors. Is there something I am missing in order to be able to compile in c++ mode rather that c mode? ---------------------------------------- Benjamin G. Miller Consultant Data Communications Consulting inc. ---------------------------------------- This message transmited on 100% recycled electrons. >>> Tim Newsham 10/28 4:22 PM >>> > I have tried the lines you have indicated below but I get a bunch of = > errors like > the one below: > > C:=5C=5Cgnuwin32=5C=5Cb18=5C=5CH-i386-cygwin32=5C=5Clib=5C=5Cgcc-lib=5C=5Ci= > 386-cygwin32=5C=5Ccygnus-2.7.2-970404=5C=5C../../../../i386-cygwin32/includ= > e/Windows32/Sockets.h:824: syntax error before `__attribute__=27 I don't get any errors like that. Here is an example program that compiles and runs for me: /* * winsock.c * example of using winsock calls with cygwin * * to build: gcc winsock.c -lwsock32 */ #define Win32_Winsock #include void xperror(int bool, char *mesg) { if(bool) { printf("%s: error %d\n", mesg, GetLastError()); exit(1); } } void init() { static int initdone = 0; static WSADATA data; if(initdone == 0) { WSAStartup(MAKEWORD(1, 1), &data); initdone = 1; } } int main(int argc, char **argv) { SOCKADDR_IN ad; SOCKET s; int addr, res; init(); if(argc != 2) { printf("usage: %s hostIP\n", argv[0]); exit(1); } addr = inet_addr(argv[1]); s = socket(AF_INET, SOCK_STREAM, 0); xperror(s == INVALID_SOCKET, "socket"); memset(&ad, 0, sizeof(ad)); ad.sin_family = AF_INET; ad.sin_port = htons(23); ad.sin_addr.s_addr = addr; res = connect(s, (LPSOCKADDR)&ad, sizeof(ad)); xperror(res == SOCKET_ERROR, "connect"); printf("connected\n"); closesocket(s); return 0; } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".