Network - Connection set blocking to true while connecting.
This commit is contained in:
parent
23a05bf431
commit
f31da90830
|
@ -48,8 +48,8 @@ struct ClientDataContainer
|
||||||
InitWinSock();
|
InitWinSock();
|
||||||
callbackType = NetworkProtocolCallbackType_Unknown;
|
callbackType = NetworkProtocolCallbackType_Unknown;
|
||||||
sendPostBox = new PostBox<CustomNetProtocol>();
|
sendPostBox = new PostBox<CustomNetProtocol>();
|
||||||
connection.SetBlockingMode(false);
|
|
||||||
connection.InitiateClient();
|
connection.InitiateClient();
|
||||||
|
connection.SetBlockingMode(false);
|
||||||
}
|
}
|
||||||
ClientDataContainer(IThreadObject* o, unsigned int socket )
|
ClientDataContainer(IThreadObject* o, unsigned int socket )
|
||||||
:connection(socket), ID(currID++)
|
:connection(socket), ID(currID++)
|
||||||
|
@ -204,17 +204,17 @@ NetworkClient::~NetworkClient()
|
||||||
|
|
||||||
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
|
||||||
{
|
{
|
||||||
|
privateData->data->connection.SetBlockingMode(true);
|
||||||
int result = this->privateData->data->connection.Connect(port, serverIP);
|
int result = this->privateData->data->connection.Connect(port, serverIP);
|
||||||
|
|
||||||
//Connect has succeeded
|
//Connect has succeeded
|
||||||
if(result == 0)
|
if(result == 0)
|
||||||
{
|
{
|
||||||
privateData->data->thread.Start();
|
privateData->data->thread.Start();
|
||||||
|
privateData->data->connection.SetBlockingMode(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
privateData->data->connection.SetBlockingMode(false);
|
|
||||||
|
|
||||||
//Connect has failed
|
//Connect has failed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ int main()
|
||||||
|
|
||||||
//Connect to server
|
//Connect to server
|
||||||
//errorCode = client->Connect(15151, "193.11.186.101");
|
//errorCode = client->Connect(15151, "193.11.186.101");
|
||||||
errorCode = client.Connect(15151, "127.0.0.1");
|
errorCode = client.Connect(15151, "193.11.187.62");
|
||||||
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
|
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
|
||||||
|
|
||||||
if(errorCode != 1)
|
if(errorCode != 1)
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "../NetworkDependencies/WinsockFunctions.h"
|
#include "../NetworkDependencies/WinsockFunctions.h"
|
||||||
#include "../NetworkAPI/NetworkServer.h"
|
#include "../NetworkAPI/NetworkServer.h"
|
||||||
|
#include "../NetworkAPI/CustomNetProtocol.h"
|
||||||
|
#include "../NetworkAPI/NetworkCallbackHelper.h"
|
||||||
|
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
vector<NetworkClient> clients;
|
|
||||||
std::mutex m;
|
std::mutex m;
|
||||||
|
vector<NetworkClient> clients;
|
||||||
|
|
||||||
void proc(NetworkClient client)
|
void proc(NetworkClient client)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue