2022-07-14 16:05:56 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
class Socket {
|
|
|
|
|
|
|
|
public:
|
2022-07-14 21:07:14 +00:00
|
|
|
Socket ();
|
|
|
|
int init(std::string hostname, int port);
|
2022-07-14 16:05:56 +00:00
|
|
|
|
|
|
|
int send (std::string message);
|
|
|
|
int operator<< (std::string message);
|
|
|
|
|
|
|
|
std::string receive ();
|
|
|
|
void operator>> (std::string& ret);
|
|
|
|
|
|
|
|
private:
|
2022-07-14 21:07:14 +00:00
|
|
|
int _port;
|
|
|
|
std::string _hostname;
|
|
|
|
int _socket_fd;
|
|
|
|
bool _initialized;
|
2022-07-14 16:05:56 +00:00
|
|
|
|
|
|
|
};
|