Hi.
I was trying to make this teste server, but i have a problem. The socket can't be opened. The code compiled well, but when i launch the .exe file, i get the error "Can't creat socket." and I just don't understand why. Here his an extract of the code:
Another problem was that hostent* was not recognized besides including Winsock2.h and compiling with Ws2_32.lib.Code:#define _WINSOCKAPI_ #include <stdio.h> #include <string.h> #include <windows.h> #include <Winsock2.h> #include "useful.h" //requires Ws2_32.lib int main(int argc, char** argv) { SOCKET sockfd; int rm; char message[256]; struct sockaddr_in serv_addr; //hostent* localHost; //char* localIP; if(argc != 3) error_dump("Invalid parameters.\n"); if((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) error_dump("Can't creat socket.\n");
Can someone help me?
Thanks a lot.
My best regards.
PS: I've windows XP sp2



LinkBack URL
About LinkBacks


