1
0
Fork 0

Make TCPClientSocket field private

Also, it is a pointer, therefore prevent bugs by disallowing copying
and assignment.
This commit is contained in:
Patryk Obara 2020-02-18 21:01:30 +01:00 committed by Patryk Obara
parent 0e32c002ae
commit 75478a9a39
2 changed files with 8 additions and 7 deletions

View file

@ -93,9 +93,6 @@ TCPClientSocket::TCPClientSocket(int platformsocket)
TCPClientSocket::TCPClientSocket(TCPsocket source)
{
#ifdef NATIVESOCKETS
nativetcpstruct=0;
#endif
if (!SDLNetInited) {
if (SDLNet_Init() == -1) {
LOG_MSG("SDLNet_Init failed: %s\n", SDLNet_GetError());
@ -116,9 +113,6 @@ TCPClientSocket::TCPClientSocket(TCPsocket source)
TCPClientSocket::TCPClientSocket(const char* destination, Bit16u port)
{
#ifdef NATIVESOCKETS
nativetcpstruct=0;
#endif
if (!SDLNetInited) {
if (SDLNet_Init() == -1) {
LOG_MSG("SDLNet_Init failed: %s\n", SDLNet_GetError());

View file

@ -62,9 +62,11 @@ public:
TCPClientSocket(TCPsocket source);
TCPClientSocket(const char* destination, Bit16u port);
#ifdef NATIVESOCKETS
Bit8u* nativetcpstruct;
TCPClientSocket(int platformsocket);
#endif
TCPClientSocket(const TCPClientSocket&) = delete; // prevent copying
TCPClientSocket& operator=(const TCPClientSocket&) = delete; // prevent assignment
~TCPClientSocket();
// return:
@ -88,6 +90,11 @@ public:
bool SendByteBuffered(Bit8u data);
private:
#ifdef NATIVESOCKETS
Bit8u *nativetcpstruct = nullptr;
#endif
TCPsocket mysock = 0;
SDLNet_SocketSet listensocketset = nullptr;