mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-16 20:39:15 +01:00
Don't wait forever
This commit is contained in:
parent
09bca43d1c
commit
331320c6e5
@ -103,14 +103,28 @@ void C64::c64_ctor1(void)
|
||||
this->peer = NULL;
|
||||
|
||||
if (fixme_tmp_network_server) {
|
||||
int i;
|
||||
this->peer = new Network("localhost", this->server_port, true);
|
||||
this->network_connection_type = MASTER;
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
printf("Waiting for connection, try %d of 20\n", i+1);
|
||||
if (this->peer->WaitForConnection() == true)
|
||||
break;
|
||||
}
|
||||
if (i == 20)
|
||||
{
|
||||
printf("No client connected. Bye\n");
|
||||
delete this->peer;
|
||||
this->peer = NULL;
|
||||
}
|
||||
}
|
||||
if (fixme_tmp_network_client)
|
||||
{
|
||||
strcpy(this->server_hostname, fixme_tmp_network_client);
|
||||
this->peer = new Network(this->server_hostname, this->server_port, false);
|
||||
this->network_connection_type = CLIENT;
|
||||
this->peer->ConnectToPeer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,9 +496,9 @@ bool Network::ReceiveUpdate()
|
||||
return this->ReceiveUpdate(this->ud, NETWORK_UPDATE_SIZE, &tv);
|
||||
}
|
||||
|
||||
bool Network::ReceiveUpdateBlocking()
|
||||
bool Network::ReceiveUpdate(struct timeval *tv)
|
||||
{
|
||||
return this->ReceiveUpdate(this->ud, NETWORK_UPDATE_SIZE, NULL);
|
||||
return this->ReceiveUpdate(this->ud, NETWORK_UPDATE_SIZE, tv);
|
||||
}
|
||||
|
||||
bool Network::ReceiveUpdate(NetworkUpdate *dst, size_t total_sz,
|
||||
@ -749,7 +749,14 @@ bool Network::DecodeUpdate(uint8 *screen, uint8 *js)
|
||||
|
||||
bool Network::WaitForConnection()
|
||||
{
|
||||
return this->ReceiveUpdateBlocking();
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
if (this->ReceiveUpdate(&tv) == true)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Network::ConnectToPeer()
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
|
||||
bool ReceiveUpdate();
|
||||
|
||||
bool ReceiveUpdateBlocking();
|
||||
bool ReceiveUpdate(struct timeval *tv);
|
||||
|
||||
static bool StartNetworkServer(int port);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user