mnClientConnected

This is used in client (mnConnect) and server (mnStartServer) state to check the status of a connection either to a client or to a server.

In client state, if the instance is initialized (using mnConnect) and this command returns 0, the instance will have been uninitialized (by this command) using mnFinish and all subsequent commands that require the instance to be initialized will fail.

This command operates differently when graceful disconnect is enabled (mnEnableGracefulDisconnect). By default graceful disconnect is disabled.

When graceful disconnect is disabled this command may return:

- C_NOT_CONNECTED (0) to indicate that the client is not connected.

- C_CONNECTED (1) to indicate that the client is connected.

When graceful disconnect is enabled this command may return:

- C_NOT_CONNECTED (0) to indicate that the client is not connected at all.

- C_CONNECTED (1) to indicate that the client is fully connected.

- C_NO_SEND (2) to indicate that you have used mnShutdownClient and so all further attempts to send will fail, but new data can still be received.

- C_NO_RECV (3) to indicate that you have not used mnShutdownClient and can still send, but mnShutdownClient has been used on the other end so no more new data can be received. Data that is currently in the TCP packet queue can still be received via mnRecvTCP.

- C_NO_SEND_RECV (4) to indicate that you have used mnShutdownClient and so all further attempts to send will fail and mnShutdownClient has been used on the other end and so no more new data can be received. However, there is still data in the TCP packet queue that can still be dealt with. When the TCP packet queue is empty mnClientConnected will return 0 and the client ID will be freed by mnClientJoined.

See mnEnableGracefulDisconnect for more information on the graceful disconnect procedure. There is also demo code in the Graceful Disconnect folder which demonstrates the procedure.

Parameters

int ClientID: This is the client ID of the client to check. This can be ignored in client state and can be set to anything.

Returns (Integer)

When graceful disconnect is disabled (it is by default):

1 if the client is connected

0 if the client is not connected

-1 if an error occurred.

When graceful disconnect is enabled (see above for more detail):

0 if the client is not connected at all.

1 if the client is fully connected.

2 if mnShutdownClient has been used and all further send operations will fail.

3 if mnShutdownClient has been used on the other end and so no new data can be received.

4 if mnShutdownClient has been used on both ends and so no data can be transferred.

Present in

DBP

C++

.Net




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