generated from sigonasr2/CPlusPlusProjectTemplate
The good old Neggs are back.
https://sigonasr2.itch.io/meerca-chase-clone
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
758 B
31 lines
758 B
#include "pixelGameEngine.h"
|
|
#include "sys/socket.h"
|
|
#include "netinet/in.h"
|
|
#include <unistd.h>
|
|
#include <arpa/inet.h>
|
|
|
|
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);
|
|
} |