From: newsham AT aloha DOT net (Tim Newsham) Subject: Re: compiling winsock apps 28 Oct 1997 20:56:25 -0800 Message-ID: <199710282122.LAA21480.cygnus.gnu-win32@haleakala.aloha.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: bgmiller AT dccinc DOT com (Ben Miller) Cc: newsham AT aloha DOT net, gnu-win32 AT cygnus DOT com > 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".