---
name: "CL_NetGame"
section: "3"
platform: "linux"
package: "clanlib0-common-dev"
version: "0.4.4-8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/CL_NetGame"
---

# CL\_NetGame(3)

CL\_NetGame is the interface to communcation with a network game.

## NAME

CL\_NetGame - CL\_NetGame is the interface to communcation with a network game.

## CLASS MEMBERS

- virtual **~CL\_NetGame**()

  - virtual const CL\_NetComputer \***get\_server**()

  - virtual const CL\_NetGroup \***get\_all**()

  - virtual bool **peek**(

  ```
  int channel)
  ```

- virtual CL\_NetMessage **receive**(

  ```
  int channel,
  int timeout=-1)
  ```

- virtual void **send**(

  ```
   const int dest_channel,
  const CL_NetGroup *dest,
  const CL_NetMessage &message,
  bool reliable = true)
  ```

- virtual void **send**(

  ```
   const int dest_channel,
  const CL_NetGroup *dest,
  const CL_NetMessage &message,
  bool reliable = true)
  ```

- virtual CL\_NetComputer \***receive\_computer\_leave**()

  - virtual const CL\_NetComputer \***receive\_computer\_join**()

  - virtual const CL\_NetComputer \***receive\_computer\_rejoin**()

  - virtual bool **receive\_game\_closed**()

  - virtual int **access\_status**(

  ```
  int channel)
  ```

- virtual bool **is\_writable**(

  ```
  int channel)
  ```

- virtual bool **is\_readable**(

  ```
  int channel)
  ```

- virtual int **receive\_access\_changed**()

  - virtual void **set\_access**(

  ```
   int channel,
  const CL_NetGroup *group,
  int access_rights=ACCESS_CHANNEL_READ|ACCESS_CHANNEL_WRITE)
  ```

- virtual void **set\_access**(

  ```
   int channel,
  const CL_NetGroup *group,
  int access_rights=ACCESS_CHANNEL_READ|ACCESS_CHANNEL_WRITE)
  ```

## MEMBERS WITH DESCRIPTIONS

- virtual **~CL\_NetGame**()

  ```
  Description:
  ```

- virtual const CL\_NetComputer \***get\_server**()

  ```
  Description:
  ```

  The server of the network game.

- virtual const CL\_NetGroup \***get\_all**()

  ```
  Description:
  ```

  A group of all the computers in the netgame.

- virtual bool **peek**(

  ```
  int channel)
  ```

  ```
  Parameters:
  channel - Channel to look for a message.
  ```

  ```
  Description:
  ```

  Returns true if a message is available on the specified channel.

  ```
  Return value:
  ```

  True if a message is available on the specified channel.

- virtual CL\_NetMessage **receive**(

  ```
  int channel,
  int timeout=-1)
  ```

  ```
  Parameters:
  channel - Channel to look for a message.
  timeout - Timeout, -1 means block forever.
  ```

  ```
  Description:
  ```

  Receives a message from the specified channel. The call is blocking, sodon*t call it if you aren*t completly sure it will arrive (unless you seta timeout).

  ```
  Return value:
  ```

  The message received from the specified channel.

- virtual void **send**(

  ```
   const int dest_channel,
  const CL_NetGroup *dest,
  const CL_NetMessage &message,
  bool reliable = true)
  ```

  ```
  Parameters:
  dest - Computer in the netgame to receive the message.
  dest_channel - Netchannel the message is sent to.
  message - Data in the message sent. All the data from 'message' is duplicated before this function returns.
  reliable - Arrival reliability. True guarantees arrival (use TCP/Pony express), false doesn't (use UDP/US Mail).
  dest - The group of computers to receive the message.
  dest_channel - Netchannel the message is sent to.
  message - Data in the message sent. All the data from 'message' is duplicated before this function returns.
  reliable - Arrival reliability. True guarantees arrival (use TCP/Pony express), false doesn't (use UDP/US Mail).
  ```

  ```
  Description:
  ```

  Sends a message to the computer *dest* at netchannel *dest\_port*.Sends a message to a group of computers at netchannel *dest\_channel*.

- virtual void **send**(

  ```
   const int dest_channel,
  const CL_NetGroup *dest,
  const CL_NetMessage &message,
  bool reliable = true)
  ```

  ```
  Parameters:
  dest - Computer in the netgame to receive the message.
  dest_channel - Netchannel the message is sent to.
  message - Data in the message sent. All the data from 'message' is duplicated before this function returns.
  reliable - Arrival reliability. True guarantees arrival (use TCP/Pony express), false doesn't (use UDP/US Mail).
  dest - The group of computers to receive the message.
  dest_channel - Netchannel the message is sent to.
  message - Data in the message sent. All the data from 'message' is duplicated before this function returns.
  reliable - Arrival reliability. True guarantees arrival (use TCP/Pony express), false doesn't (use UDP/US Mail).
  ```

  ```
  Description:
  ```

  Sends a message to the computer *dest* at netchannel *dest\_port*.Sends a message to a group of computers at netchannel *dest\_channel*.

- virtual CL\_NetComputer \***receive\_computer\_leave**()

  ```
  Description:
  ```

  Returns the first (if more) computer that has left the game, or NULL ifnone. The next time the function is called, it returns the next computer,etc.It is up the game to delete the netcomputer, if it do want its object to beremoved from the all group. Note that a computer not deleted will rejoinwith the same computer object, if it isn't deleted.

  ```
  Return value:
  ```

  The netcomputer that left the game - delete it to remove it from the all group.

- virtual const CL\_NetComputer \***receive\_computer\_join**()

  ```
  Description:
  ```

  Returns the first (if more) computer that is joining the game, or NULL ifnone. The next time the function is called, it returns the next computer,etc.

  ```
  Return value:
  ```

  The computer joining the game.

- virtual const CL\_NetComputer \***receive\_computer\_rejoin**()

  ```
  Description:
  ```

  Returns the first (if more) computer that is re-joining the game, or NULLif none. The next time the function is called, it returns the next computer,etc. A re-joining computer is simply a computer joining the game, that stillhavn't had its CL\_NetComputer object deleted. This provides a way torecognize a computer that was in the game.

  ```
  Return value:
  ```

  The computer re-joining the game.

- virtual bool **receive\_game\_closed**()

  ```
  Description:
  ```

  Returns true if the game was closed.

  ```
  Return value:
  ```

  True if game is closed, false otherwise.

- virtual int **access\_status**(

  ```
  int channel)
  ```

  ```
  Description:
  ```

- virtual bool **is\_writable**(

  ```
  int channel)
  ```

  ```
  Description:
  ```

- virtual bool **is\_readable**(

  ```
  int channel)
  ```

  ```
  Description:
  ```

- virtual int **receive\_access\_changed**()

  ```
  Description:
  ```

  Client side only

- virtual void **set\_access**(

  ```
   int channel,
  const CL_NetGroup *group,
  int access_rights=ACCESS_CHANNEL_READ|ACCESS_CHANNEL_WRITE)
  ```

  ```
  Description:
  ```

  Server side onlyServer side only

- virtual void **set\_access**(

  ```
   int channel,
  const CL_NetGroup *group,
  int access_rights=ACCESS_CHANNEL_READ|ACCESS_CHANNEL_WRITE)
  ```

  ```
  Description:
  ```

  Server side onlyServer side only

## SEE ALSO

All ClanLib API classes can be found in **clanlib (3)**.

## AUTHORS

Originally written by Magnus Norddahl \<*mbn@dark.x.dtu.dk*\> and Martin Starch \<*starch@dark.x.dtu.dk*\>. ClanLib is now developed by the ClanLib Development team as an Open Source project.

The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at **http://somewhere.in.the.world.org**).

See **clanlib (3)** to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.
