sockets - send HTTPS HEAD command

Hi, I've not really used sockets in my many years of programming, and now I'm in need of send'ing a HTTPS HEAD command and recv'ing the response. If some kind person could show me some code that achieves this I would be very grateful. If in the meantime I work out how to acheive my objective I will post the code into this thread.
Use libcurl compiled against OpenSSL:
http://curl.haxx.se/

There is example code on curl website.
In case anyone is interested, I have worked out how to do a socket HTTP HEAD command and recv the response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
WSADATA wsaData;
	string http;

	if (WSAStartup(MAKEWORD(2, 2), &wsaData) == 0)
	{
		struct sockaddr_in addr;

		// describe the type of the connection and what port to use
		addr.sin_family = AF_INET;
		addr.sin_port = htons(80);
		HOSTENT* hostent = gethostbyname("www.google.com");

		if (hostent)
		{
			addr.sin_addr.S_un.S_addr = (*reinterpret_cast<IPNumber*>(hostent->h_addr_list[0]));
			memset(addr.sin_zero, '\0', sizeof(addr.sin_zero));

			// create and bind the socket
			int sock = socket(PF_INET, SOCK_STREAM, 0);
			bind(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr));

			// connect
			connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr));

			// send the HTTP HEAD request
			char* msg = "HEAD / HTTP/1.1\r\nHost: www.google.com\r\n\r\n";
			send(sock, msg, strlen(msg), 0);

			// get back the response
			char buf[1024];
			memset(buf, 0, 1024);
			int n = recv(sock, buf, 1024, MSG_PEEK);
			int len = strlen(buf);

			shutdown(sock, 2);
		}
	}

	WSACleanup();
Topic archived. No new replies allowed.