Network - Connection set blocking to true while connecting.

This commit is contained in:
Pontus Fransson 2013-12-17 09:05:32 +01:00
parent 23a05bf431
commit f31da90830
3 changed files with 7 additions and 5 deletions

View File

@ -48,8 +48,8 @@ struct ClientDataContainer
InitWinSock();
callbackType = NetworkProtocolCallbackType_Unknown;
sendPostBox = new PostBox<CustomNetProtocol>();
connection.SetBlockingMode(false);
connection.InitiateClient();
connection.SetBlockingMode(false);
}
ClientDataContainer(IThreadObject* o, unsigned int socket )
:connection(socket), ID(currID++)
@ -204,17 +204,17 @@ NetworkClient::~NetworkClient()
bool NetworkClient::Connect(unsigned short port, const char serverIP[])
{
privateData->data->connection.SetBlockingMode(true);
int result = this->privateData->data->connection.Connect(port, serverIP);
//Connect has succeeded
if(result == 0)
{
privateData->data->thread.Start();
privateData->data->connection.SetBlockingMode(false);
return true;
}
privateData->data->connection.SetBlockingMode(false);
//Connect has failed
return false;
}

View File

@ -31,7 +31,7 @@ int main()
//Connect to server
//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);
if(errorCode != 1)

View File

@ -4,12 +4,14 @@
#include <mutex>
#include "../NetworkDependencies/WinsockFunctions.h"
#include "../NetworkAPI/NetworkServer.h"
#include "../NetworkAPI/CustomNetProtocol.h"
#include "../NetworkAPI/NetworkCallbackHelper.h"
using namespace Oyster::Network;
using namespace std;
vector<NetworkClient> clients;
std::mutex m;
vector<NetworkClient> clients;
void proc(NetworkClient client)
{