third time is the charm

fixed send and recieve functions in IConnection
This commit is contained in:
Sam Mario Svensson 2013-11-19 12:55:54 +01:00
parent 89ce3dd0d1
commit adcef51227
3 changed files with 8 additions and 8 deletions

View File

@ -101,12 +101,12 @@ void Connection::Disconnect()
closesocket(mySocket); closesocket(mySocket);
} }
bool Connection::Send(int socket , const char message[]) bool Connection::Send(const char message[])
{ {
int nBytes; int nBytes;
unsigned long messageSize = strlen(message); unsigned long messageSize = strlen(message);
if((nBytes = send(socket, message , messageSize, 0)) == SOCKET_ERROR) if((nBytes = send(mySocket, message , messageSize, 0)) == SOCKET_ERROR)
{ {
//Send failed! //Send failed!
return false; return false;
@ -115,10 +115,10 @@ bool Connection::Send(int socket , const char message[])
return true; return true;
} }
int Recieve(int socket, char message[]) int Connection::Recieve(char message[])
{ {
int nBytes; int nBytes;
nBytes = recv(socket, message , 255, 0); nBytes = recv(mySocket, message , 255, 0);
if(nBytes == SOCKET_ERROR) if(nBytes == SOCKET_ERROR)
{ {
//Recv failed //Recv failed

View File

@ -20,8 +20,8 @@ class Connection : public IConnection
virtual bool Connect( unsigned short port , const char serverName[] ); virtual bool Connect( unsigned short port , const char serverName[] );
virtual bool InitiateServer( unsigned short port ); virtual bool InitiateServer( unsigned short port );
virtual void Disconnect(); virtual void Disconnect();
virtual bool Send(int socket , const char message[]); virtual bool Send(const char message[]);
virtual int Recieve(int socket); virtual int Recieve(char message[]);
virtual int Listen(); virtual int Listen();
}; };

View File

@ -14,8 +14,8 @@ class IConnection
virtual bool Connect( unsigned short port, const char serverName[] ) = 0; virtual bool Connect( unsigned short port, const char serverName[] ) = 0;
virtual bool InitiateServer( unsigned short port ) = 0; virtual bool InitiateServer( unsigned short port ) = 0;
virtual void Disconnect() = 0; virtual void Disconnect() = 0;
virtual bool Send(int socket , const char message[]) = 0; virtual bool Send( const char message[] ) = 0;
virtual int Recieve( int socket ) = 0; virtual int Recieve(char message[]) = 0;
virtual int Listen() = 0; virtual int Listen() = 0;
}; };