From a1d5bbb321dc1b89247b7d3c278b5f610e88907a Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Sep 2004 15:20:45 +0000 Subject: [PATCH] Removed = operator. Fixed method of obtaining address. --- stepmania/src/ezsockets.cpp | 45 +++++++++---------------------------- stepmania/src/ezsockets.h | 7 +++--- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/stepmania/src/ezsockets.cpp b/stepmania/src/ezsockets.cpp index 6759639f5d..7cdccd36ae 100644 --- a/stepmania/src/ezsockets.cpp +++ b/stepmania/src/ezsockets.cpp @@ -8,8 +8,6 @@ #include "ezsockets.h" -#include "global.h" // StepMania only includes - #if defined(_XBOX) #elif defined(_WINDOWS) // We need the WinSock32 Library on Windows #pragma comment(lib,"wsock32.lib") @@ -115,8 +113,19 @@ typedef int socklen_t; bool EzSockets::accept(EzSockets& socket) { + if (!blocking && !CanRead()) return false; + + #if defined(HAVE_INET_NTOP) + char buf[INET_ADDRSTRLEN]; + + inet_ntop(AF_INET, &addr.sin_addr, buf, INET_ADDRSTRLEN); + address = buf; + + #elif defined(HAVE_INET_NTOA) + address = inet_ntoa(addr.sin_addr); + #endif int length = sizeof(socket); @@ -389,33 +398,6 @@ ostream& operator<<(ostream &os, EzSockets &obj) return os; } -EzSockets& EzSockets::operator=(const EzSockets &socket) -{ - if (this == &socket) { - return *this; - } - else - { - blocking = socket.blocking; - fromAddr = socket.fromAddr; - fromAddr_len = socket.fromAddr_len; - string inBuffer = socket.inBuffer; - outBuffer = socket.outBuffer; - state = socket.state; - lastCode = socket.lastCode; //Used for debugging purposes - MAXCON = socket.MAXCON; - sock = socket.sock; - addr = socket.addr; - if (scks == NULL) - scks = new fd_set; - *scks = *socket.scks; - if (scks == NULL) - times = new timeval; - *times = *socket.times; - return *this; - } -} - /**************************\ | Internal Data System | @@ -462,11 +444,6 @@ int EzSockets::pWriteData(const char* data, int dataSize) return send(sock, data, dataSize, 0); } -in_addr EzSockets::GetIn_addr() -{ - return addr.sin_addr; -} - /* * (c) 2003-2004 Josh Allen, Charles Lohr, and Adam Lowman * All rights reserved. diff --git a/stepmania/src/ezsockets.h b/stepmania/src/ezsockets.h index e8b3e04f8b..2dea68d5b6 100644 --- a/stepmania/src/ezsockets.h +++ b/stepmania/src/ezsockets.h @@ -18,6 +18,7 @@ #include #include #include +#include "global.h" // StepMania only includes #if defined(_XBOX) // Summary : WinsockX is bad, XTL is good. @@ -93,8 +94,6 @@ public: char operator[] (int i); //Access buffer friend istream& operator>>(istream& is, EzSockets& obj); friend ostream& operator<<(ostream& os, const EzSockets& obj); - EzSockets& operator=(const EzSockets &socket); - bool blocking; enum SockState @@ -122,12 +121,12 @@ public: int pReadData(char * data); int pWriteData(const char * data, int dataSize); - in_addr GetIn_addr(); - SockState state; int lastCode; //Used for debugging purposes + CString address; + private: //Only necessiary in windows, xbox