mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 20:02:40 +01:00
27 lines
402 B
C++
27 lines
402 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <netinet/in.h>
|
|
|
|
|
|
class TcpSocket
|
|
{
|
|
public:
|
|
TcpSocket();
|
|
~TcpSocket() { disconnect(); }
|
|
|
|
bool bind(short port);
|
|
bool listen(TcpSocket& client);
|
|
|
|
void recv(std::string& out, size_t len);
|
|
size_t send(const std::string& str);
|
|
void disconnect();
|
|
|
|
std::string getRemoteAddress() const;
|
|
short getRemotePort() const;
|
|
|
|
private:
|
|
int sock;
|
|
sockaddr_in addr;
|
|
};
|