From: joco AT wxs DOT nl (Johan Compagner) Subject: Socket and a plain win32 program (without cygnus dll) 13 Jan 1999 16:26:59 -0800 Message-ID: <001c01be3e7c$9be2ee40$05ff79c3.cygnus.gnu-win32@joco.wxs.nl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit To: hi, How can i get the below code working without the need of the Cygwin? i also hoop that the exe size can be a bit smaller, it is now 300K I tried to include and drop the sys/socket and netinet/in because those files generates many errors with -mno-cygwin option. gcced with : gcc -mno-cygwin -lwsock32 test.c i think that if you don't use cygwin you must use winsock it self am i right? so the -lwsock32 is neccesary? thx for you support. Johan Compagner #include #include #include #define PORT 7080 int main(int argc, char *argv[]) { int sock; char* adres = "127.0.0.1"; int nbytes; char* message; char* hostname = (char*)malloc(sizeof(char[14])); struct sockaddr_in name; struct hostent *host; if(argc < 2) { printf ("Wrong Usage: java_program_to_start"); return 0; } if(argc > 2) { adres = argv[1]; message = argv[2]; } else message = argv[1]; gethostname (hostname, strlen (hostname)); /* Create the socket. */ sock = socket (PF_INET, SOCK_STREAM, 0); if (sock < 0) { perror ("socket (client)"); return 1; } /* Connect to the server. */ name.sin_family = AF_INET; name.sin_port = htons (PORT); name.sin_addr.s_addr = inet_addr(adres); if (0 > connect (sock,(struct sockaddr *) &name,sizeof (name))) { perror ("connect (client)"); return 1; } /* Send data to the server. */ nbytes = write (sock, message, strlen (message)); if (nbytes < 0) { perror ("write"); return 1; } close (sock); printf("launched %s at %s (%s)", message , hostname ,inet_ntoa(name.sin_addr)); 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".