Antw: [Dev-C++] About headers like socket.h
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Frank W. <F.W...@wi...> - 2003-10-28 16:34:45
|
Hello Alain, on default the DevC++ IDE uses the Mingw system that comes with the GNU compiler and some of the GNU tools. But as far as I know it is not Linux compliant. If you want to use your Linux code to compile on Windwos maschines or port some programs you should try Cygwin ( www.cygwin.com ) that comes with all the stuff (headers libs) you have on Linux. I took a short look and found the socket.h in the /inc/sys directory of my cygwin installation. Hope this helps, Frank >>> "Alain Paschoud" <ala...@ge...> 10/28 4:30 >>> Hi all, I'm new to dev-cpp, and I need to accept a TCP connection. As I did under Linux, I will use the bind and accepts functions. But to do that, I need to include the <sys/socket.h> header file. I did it (see below), but there is no socket.h file in the include directory of dev-cpp (result : accept_con.c sys\socket.h: No such file or directory). Here are my questions : Is there every required headers with Dev-cpp to do network programming ? Is there every necessary libraries ? Do I have to download something more to use sockets ? Best regards, and thank you for any help. Alain Paschoud **** Code example below **** #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #define MYPORT 3490 int accept_con() { int sockfd; struct sockaddr_in my_addr; sockfd = socket(AF_INET, SOCK_STREAM, 0); // do some error checking! my_addr.sin_family = AF_INET; // host byte order my_addr.sin_port = htons(MYPORT); // short, network byte order my_addr.sin_addr.s_addr = htons(INADDR_ANY); memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct // don't forget your error checking for bind(): bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)); /* Accept connection */ accept(sockfd, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)); } ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |