Recast  1
Game with custom magic
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
SocketTCP.hpp
Go to the documentation of this file.
1 
11 #ifndef RECAST_SERVER_SOCKET_TCP_HPP
12 #define RECAST_SERVER_SOCKET_TCP_HPP
13 
14 #include "NetworkUtils.hpp"
15 #include "Socket.hpp"
16 
17 using namespace std;
18 
19 class SocketTCP : public Socket {
20 public:
21  using Socket::Socket;
22  SocketTCP(uint32_t port, uint32_t queueSize) : Socket::Socket() {
23  socketBoundPort = port;
24  socketQueueSize = queueSize;
25  createServerSocket();
26  }
27 public:
28  void setRecvTimeout(int seconds, int microseconds);
29  void createServerSocket() override;
30  void createServerSocket(uint32_t port, uint32_t queueSize);
31 
32  void send(const string &str);
33  void sendBytes(const char *data, size_t num);
34  string recv();
35  string recv(size_t bytes);
36  string recvTimed(int timeout);
37  char* recvBytes(size_t num);
38  bool hasData();
39  shared_ptr<SocketTCP> accept();
40 private:
41  uint32_t socketQueueSize;
42 };
43 
44 #endif //RECAST_SERVER_SOCKET_TCP_HPP
Socket()
Definition: Socket.hpp:18
Definition: SocketTCP.hpp:19
SocketTCP(uint32_t port, uint32_t queueSize)
Definition: SocketTCP.hpp:22
Definition: Socket.hpp:16
Basic networking utils header file.
Socket abstract utils header file.