generated from AfonsoCMSousa/CPP-Template
34 lines
542 B
C++
34 lines
542 B
C++
#ifndef NET_HPP
|
|
#define NET_HPP
|
|
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <cstring>
|
|
#include <sys/socket.h>
|
|
#include <arpa/inet.h>
|
|
#include <unistd.h>
|
|
|
|
#include "server_structs.h"
|
|
|
|
using namespace std;
|
|
|
|
class Socket {
|
|
private:
|
|
// Socket file descriptor
|
|
int sock;
|
|
struct sockaddr_in server_addr;
|
|
// Socket Data
|
|
api_packet packet_data;
|
|
|
|
|
|
public:
|
|
Socket();
|
|
~Socket();
|
|
|
|
void connect(const char *ip, uint16_t port);
|
|
void send();
|
|
void send(const api_packet &data);
|
|
};
|
|
|
|
#endif // NET_HPP
|