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)
|
bool Connection::InitiateServer(unsigned short port)
|
||||||
{
|
{
|
||||||
this->socket = ::socket(AF_INET, SOCK_STREAM, 0);
|
if(!initiateSocket())
|
||||||
if(this->socket == SOCKET_ERROR)
|
|
||||||
{
|
{
|
||||||
//Error opening socket!
|
//Error opening socket!
|
||||||
return false;
|
return false;
|
||||||
|
@ -69,10 +68,8 @@ bool Connection::InitiateServer(unsigned short port)
|
||||||
|
|
||||||
bool Connection::InitiateClient()
|
bool Connection::InitiateClient()
|
||||||
{
|
{
|
||||||
this->socket = ::socket(AF_INET, SOCK_STREAM, 0);
|
if(!initiateSocket())
|
||||||
if(this->socket == SOCKET_ERROR)
|
|
||||||
{
|
{
|
||||||
//error opening socket
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,3 +123,18 @@ int Connection::Listen()
|
||||||
|
|
||||||
return clientSocket;
|
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();
|
virtual int Listen();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool initiateSocket();
|
||||||
|
|
||||||
int socket;
|
int socket;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue