#include "pixelGameEngine.h" #include "sys/socket.h" #include "netinet/in.h" #include #include using namespace std; void runSocket() { cout << "Connecting."; int sock = socket(AF_INET,SOCK_STREAM,0); if (sock<0) { cout << "Socket connection error."; } struct sockaddr_in addr; addr.sin_family=AF_INET; addr.sin_port=htons(8080); if (inet_pton(AF_INET, "192.168.1.85", &addr.sin_addr)<=0) { cout << "Invalid address"; } int client_fd = connect(sock,(struct sockaddr*)&addr,sizeof(addr)); if (client_fd<0) { cout << "Failed to connect."; } send(sock,"GET / HTTP/1.1\n",strlen("GET / HTTP/1.1\n"),0); char buffer[1024] = {}; while (read(sock,buffer,1024)!=0) { cout << buffer << "\n"; } close(client_fd); }