I have found loads of guides to aid my process in socket programming, however i am very new to C and when I try to execute the program, it has errors with
#include <sys/socket.h>
#include <netinet/in.h>
Why is this? I am using Eclipse to do this. it wont compile and says "errors exist in this project, do you wish to carry on"
And highlights these two lines, its obvious it doesnt have those files to include.. no idea how to sort them out..
guide: http开发者_StackOverflow社区://beej.us/guide/bgnet/output/html/multipage/clientserver.html#datagram
EDIT: coding it on a wnidows box, but will have to work/run on windows boxes and different flavours of linux
You need to include either "" or <> around the include files. You also need a # symbol.
For example:
#include <sys/socket.h>
#include <netinet/in.h>
Those header files are available on unixy operating systems like FreeBSD, Mac OSX, and linux. Since you are using windows right now, you will have to use winsock, which is Windows' own implementation of the BSD sockets API and has different headers and some slightly different function names.
This is detailed in one section of Beej's guide: http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#windows
He also mentions installing cygwin which would allow you to use the headers you are using right now, but I'm not sure if that would be an option for you.
精彩评论