You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
 
 
 

33 lines
634 B

#include "../commun.h"
using namespace Bk::Net;
void http_client();
int main()
{
http_client();
return 0;
}
void http_client()
{
log(dns_lookup("edus2.rpn.ch", IpVersion::IPv4)[0])
IpAddress ip("127.0.0.1");
Socket sock(ip, PORT, IpProtocol::TCP);
if(!sock.conn())
{
perror("Couldn't connect to the end point.");
exit(1);
}
Packet packet;
std::string str = "GET / HTTP/1.1\r\n"
"Host: 127.0.0.1:10001\r\n\r\n"
"Body jylkdkjlkjlkjlkjlkj";
packet.push<char>(str.c_str(), str.length());
sock.send(packet.payload);
}