mnPollConnect

This is used to manage a non blocking connection process. Use this after mnConnect where block_until_connected is false.

You should loop whilst mnPollConnect returns 2.

You can use mnStopConnect to halt the connection process mid way through.

You must not use mnFinish on an instance that is midway through a connection process, without first using mnStopConnect.

Pseudo Code

// Start connection process

mnConnect(0,ConnectIP,ConnectPort,ConnectIP,ConnectPort,Timeout,false);

int Connect;

do{

// Check to see if connection has completed yet

Connect = mnPollConnect(0);

// If the connection was successful

if(Connect == 1)

{

Print("Successfully connected to server!");

}

// If the connection timed out

if(Connect == 0)

{

Print("Connection timed out. The server may not be available.");

Print("Press any key to exit");

WaitKey();

mnFinish(-1);

return;

}

// If an unknown error occurred during connection

if(Connect == -1)

{

Print("An unknown error occurred whilst trying to connect.");

Print("Press any key to exit");

WaitKey();

mnFinish(-1);

return;

}

// If we failed to connect because the server is full

if(Connect == -2)

{

Print("Failed to connect because the server is full");

Print("Press any key to exit");

WaitKey();

mnFinish(-1);

return;

}

// Check for escape key

if(dbEscapeKey() == 1)

{

Print("Escape key pressed: connection process aborted");

Print("Press any key to exit");

WaitKey();

// Halt connection process BEFORE clean up and exit

mnStopConnect(INST_CONNECT);

mnFinish(-1);

return;

}

}while(Connect == 2); // While connection is in progress

Parameters

int Instance: This is the instance that the command should use.

Returns (Integer)

2 if the connection is still in progress

1 if the connection was successful

0 if the connection timed out

-1 if an error occurred during connection or whilst polling

-2 if the connection request was rejected, usually because the server was full

Present in

DBP

C++

.Net




This page is in the following sections:
(2) Networking Commands
(1) Networking
(0) DarkNet Help