Removed = operator. Fixed method of obtaining address.
This commit is contained in:
+11
-34
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "ezsockets.h"
|
#include "ezsockets.h"
|
||||||
|
|
||||||
#include "global.h" // StepMania only includes
|
|
||||||
|
|
||||||
#if defined(_XBOX)
|
#if defined(_XBOX)
|
||||||
#elif defined(_WINDOWS) // We need the WinSock32 Library on Windows
|
#elif defined(_WINDOWS) // We need the WinSock32 Library on Windows
|
||||||
#pragma comment(lib,"wsock32.lib")
|
#pragma comment(lib,"wsock32.lib")
|
||||||
@@ -115,9 +113,20 @@ typedef int socklen_t;
|
|||||||
|
|
||||||
bool EzSockets::accept(EzSockets& socket)
|
bool EzSockets::accept(EzSockets& socket)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!blocking && !CanRead())
|
if (!blocking && !CanRead())
|
||||||
return false;
|
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);
|
int length = sizeof(socket);
|
||||||
|
|
||||||
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
|
socket.sock = ::accept(sock,(struct sockaddr*) &socket.addr,
|
||||||
@@ -389,33 +398,6 @@ ostream& operator<<(ostream &os, EzSockets &obj)
|
|||||||
return os;
|
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 |
|
| Internal Data System |
|
||||||
@@ -462,11 +444,6 @@ int EzSockets::pWriteData(const char* data, int dataSize)
|
|||||||
return send(sock, data, dataSize, 0);
|
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
|
* (c) 2003-2004 Josh Allen, Charles Lohr, and Adam Lowman
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include "global.h" // StepMania only includes
|
||||||
|
|
||||||
#if defined(_XBOX)
|
#if defined(_XBOX)
|
||||||
// Summary : WinsockX is bad, XTL is good.
|
// Summary : WinsockX is bad, XTL is good.
|
||||||
@@ -93,8 +94,6 @@ public:
|
|||||||
char operator[] (int i); //Access buffer
|
char operator[] (int i); //Access buffer
|
||||||
friend istream& operator>>(istream& is, EzSockets& obj);
|
friend istream& operator>>(istream& is, EzSockets& obj);
|
||||||
friend ostream& operator<<(ostream& os, const EzSockets& obj);
|
friend ostream& operator<<(ostream& os, const EzSockets& obj);
|
||||||
EzSockets& operator=(const EzSockets &socket);
|
|
||||||
|
|
||||||
|
|
||||||
bool blocking;
|
bool blocking;
|
||||||
enum SockState
|
enum SockState
|
||||||
@@ -122,12 +121,12 @@ public:
|
|||||||
int pReadData(char * data);
|
int pReadData(char * data);
|
||||||
int pWriteData(const char * data, int dataSize);
|
int pWriteData(const char * data, int dataSize);
|
||||||
|
|
||||||
in_addr GetIn_addr();
|
|
||||||
|
|
||||||
SockState state;
|
SockState state;
|
||||||
|
|
||||||
int lastCode; //Used for debugging purposes
|
int lastCode; //Used for debugging purposes
|
||||||
|
|
||||||
|
CString address;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Only necessiary in windows, xbox
|
//Only necessiary in windows, xbox
|
||||||
|
|||||||
Reference in New Issue
Block a user