Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Socket.h
Go to the documentation of this file.
1#ifndef ULT_NETWORK_SOCKET_H_INCLUDED
2#define ULT_NETWORK_SOCKET_H_INCLUDED
3
4#include <Ult/Network/Types.h>
5
6namespace Ult
7{
8
9class Packet;
10
15class Socket
16{
17public:
21 Socket();
25 ~Socket();
26
32 bool SetAsServer(int port, int numPending);
38 bool ConnectToServer(const char* ipAddr, int port);
44 bool AcceptConnection(Socket& client);
45
49 NetResult SendData(Packet& packet);
54 NetResult ReceiveData(Packet& packet, int* bytesRead);
55
57 void Disconnect();
59 bool IsConnected() const { return mSocket != INVALID_SOCKET; }
60
62 bool operator==(const Socket& rhs) { return mSocket == rhs.mSocket; }
64 void operator=(const Socket& rhs) { mSocket = rhs.mSocket; }
65
67 ULT_SOCKET GetSocket() const { return mSocket; }
68
69private:
70 ULT_SOCKET mSocket;
71};
72
73} // namespace Ult
74
75#endif // ULT_NETWORK_SOCKET_H_INCLUDED
76
#define INVALID_SOCKET
Definition Types.h:22
Definition Packet.h:16
NetResult SendData(Packet &packet)
Definition Socket.cpp:101
~Socket()
Definition Socket.cpp:11
bool SetAsServer(int port, int numPending)
Definition Socket.cpp:16
bool operator==(const Socket &rhs)
Definition Socket.h:62
Socket()
Definition Socket.cpp:7
bool ConnectToServer(const char *ipAddr, int port)
Definition Socket.cpp:44
void Disconnect()
Definition Socket.cpp:154
bool IsConnected() const
Definition Socket.h:59
ULT_SOCKET GetSocket() const
Definition Socket.h:67
NetResult ReceiveData(Packet &packet, int *bytesRead)
Definition Socket.cpp:121
void operator=(const Socket &rhs)
Definition Socket.h:64
bool AcceptConnection(Socket &client)
Definition Socket.cpp:87
int ULT_SOCKET
Definition Types.h:29
NetResult
Definition Types.h:58
Definition Archive.h:13