reconstruction in connection.
This commit is contained in:
parent
82b8ef7b05
commit
ca5e578af5
|
@ -36,8 +36,7 @@ bool Connection::Connect(unsigned short port , const char serverName[])
|
|||
|
||||
bool Connection::InitiateServer(unsigned short port)
|
||||
{
|
||||
this->socket = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(this->socket == SOCKET_ERROR)
|
||||
if(!initiateSocket())
|
||||
{
|
||||
//Error opening socket!
|
||||
return false;
|
||||
|
@ -69,10 +68,8 @@ bool Connection::InitiateServer(unsigned short port)
|
|||
|
||||
bool Connection::InitiateClient()
|
||||
{
|
||||
this->socket = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(this->socket == SOCKET_ERROR)
|
||||
if(!initiateSocket())
|
||||
{
|
||||
//error opening socket
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -126,3 +123,18 @@ int Connection::Listen()
|
|||
|
||||
return clientSocket;
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
//Private functions
|
||||
///////////////////////////////////////
|
||||
bool Connection::initiateSocket()
|
||||
{
|
||||
this->socket = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(this->socket == SOCKET_ERROR)
|
||||
{
|
||||
//error opening socket
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -30,6 +30,8 @@ namespace Oyster
|
|||
virtual int Listen();
|
||||
|
||||
private:
|
||||
bool initiateSocket();
|
||||
|
||||
int socket;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue