All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WindowsTcpSocket.h
1 // Copyright eeGeo Ltd (2012-2016), All Rights Reserved
2 
3 #pragma once
4 
5 #include "EegeoWindowsGuard.h"
6 #include "Types.h"
7 #include "ITcpSocket.h"
8 #include "ITcpSocketSet.h"
9 #include <vector>
10 
11 namespace Eegeo
12 {
13  namespace Networking
14  {
15  namespace Windows
16  {
18  {
19  public:
20  static WindowsTcpSocket* CreateListenerSocket();
21 
22  WindowsTcpSocket(SOCKET clientSocketDescriptor, sockaddr_in clientSocket);
24 
25  u64 GetSocketDescriptor() const { return static_cast<u64>(m_socketDescriptor); }
26 
27  void StartListening(int port);
28  ITcpSocket* Accept();
29  void SetNonBlocking();
30 
31  ITcpSocketSet* GetSocketSet();
32  ITcpSocketSet* GetSocketSet(const std::vector<ITcpSocket*>& clientSockets);
33 
34  ssize_t Receive(char* buffer, size_t maxBufferLength);
35  void Send(const char* data, int length) const;
36 
37  void Close();
38 
39  private:
40 
41  SOCKET m_socketDescriptor;
42  sockaddr_in m_socket;
43  };
44  }
45  }
46 }