I've started on a school project, and i got some problem when i started to program! This is my code (far from finish):
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD( 2, 2 );
int err = WSAStartup( wVersionRequested, &wsaData );
SOCKET s = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
struct addrinfo *info;
int ok = getaddrinfo("www.bt.se","80",NULL,&info);
if(ok!=0) {
WCHAR * error = gai_strerror(ok);
printf("%s\n",error);
} else while(info->ai_family != AF_INET && info->ai_next != NULL)
info = info->ai_next;
ok = connect(s, info->ai_addr, info->ai_addrlen);
char * message = "GET / HTTP/1.1\r\nHOST: www.bt.se\r\n\r\n";
ok = send(s,message,strlen(message),0);
WSACleanup();
The include files are "winsock2.h" and "Ws2tcpip.h"! When i try to compilate the program I got this output:
------ Build started: Project: Ovning1, Configuration: Debug Win32 ------
Ovning.c
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(16): warning C4013: 'printf' undefined; assuming extern returning int
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(22): error C2143: syntax error : missing ';' before 'type'
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): error C2065: 'message' : undeclared identifier
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): warning C4024: 'send' : different types for formal and actual parameter 2
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): error C2065: 'message' : undeclared identifier
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int'
c:\documents and settings\fredrich\desktop\lokala nätverk\ovning1\ovning1\ovning.c(23): warning C4024: 'strlen' : different types for formal and actual parameter 1
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Anyone who knows wy these error occurs?