I've Read The Beej's Network Programming Guide And made a Basic network Code in DEV-Cpp :
#include <winsock.h>
int main()
{
WSADATA WSAData;
int server;
WSAStartup(MAKEWORD(1,0), &WSAData);
int port = 6666;
SOCKADDR_IN sinserv;
sinserv.sin_family=AF_INET;
sinserv.sin_addr.s_addr=INADDR_ANY;
sinserv.sin_port=htons(port);
server=socket(AF_INET,SOCK_STREAM,0);
bind(server,(SOCKADDR*)&sinserv,sizeof(sinserv));
listen(server,0);
}
and i got the compiling errors:
Quote:
[Linker error] undefined reference to `WSAStartup@8' [Linker error] undefined reference to `htons@4' [Linker error] undefined reference to `bind@12' [Linker error] undefined reference to `socket@12' [Linker error] undefined reference to `listen@8' ld returned 1 exit status
In addition, you want to include <winsock2.h> instead of <winsock.h>, and you want to include that before you include <windows.h>.
Also, you want to call WSAStartup() with version 2,2 of WinSock, instead of the 1,0 you have there now. Version 1,0 was very buggy, and when you say you want version 1,0, you get all the bugs, too.
Yes, you can still use the same functions; you just will get more of the behavior you'd expect and less of behavior that goes against the documentation.