monitor.Client Class Reference

Static class for TCP client More...

## Public Member Functions

delegate void | ReadEvent (string msg, byte[] buffer)
| Callback to send received message to upper level More...

## Static Public Member Functions

static bool | Open (string host)
| Open connection to server "host", on default port number. More...
static bool | Open (string host, int port)
| Open connection to server "host", with port number "port" More...
static void | Close ()
| Close connection to server More...
static void | Write (string mes)
| Write a string to server More...

## Public Attributes

const string | defaultIP = "localhost"
| Default server name More...
const int | defaultPort = 4500
| Default server port number More...

## Static Public Attributes

static ReadEvent | readEvent = null

## Static Private Member Functions

static void | ReadCallback (IAsyncResult ar)
| Callback call by stream.BeginRead after reception of newLength data More...

## Private Attributes

const int | BufferMaxSize = 512
| Size of internal buffer used when reading data from server More...

## Static Private Attributes

static TcpClient | client = null
| Tcp client object More...
static NetworkStream | stream = null
| Stream object used for communication More...
static byte [] | buffer = new byte[BufferMaxSize]
| Internal buffer used when reading data from server More...
static byte [] | receiveBuffer
| buffer containing received message from TCP server Used to concatenate internal buffers into one More...
static int | initialReceiveBufferIndex = 0
static StringBuilder | message = new StringBuilder()
| String containing received message from tcp server More...
static int | newLength = 1
static int | packetCounter = 0

## Detailed Description

Static class for TCP client

Definition at line 31 of file Client.cs.

## Member Function Documentation

## Close()

static void monitor.Client.Close | ( |  | ) |

static

Close connection to server

Definition at line 141 of file Client.cs.

## Open() [1/2]

static bool monitor.Client.Open | ( | string | host | ) |

static

Open connection to server "host", on default port number.

Returns
  true if connection succeded, false otherwise

Parameters

  host | Hostname to connect to

Definition at line 89 of file Client.cs.

## Open() [2/2]

static bool monitor.Client.Open | ( | string | host,
|  | int | port
| ) |  |

static

Open connection to server "host", with port number "port"

Returns
  true if connection succeded, false otherwise

Parameters

  host | Hostname to connect to
  port | Port number for connection

Definition at line 100 of file Client.cs.

## ReadCallback()

static void monitor.Client.ReadCallback | ( | IAsyncResult | ar | ) |

staticprivate

Callback call by stream.BeginRead after reception of newLength data

Parameters

  ar | Not sure of what is it, but needed for terminate reading

Definition at line 151 of file Client.cs.

## ReadEvent()

delegate void monitor.Client.ReadEvent | ( | string | msg,
|  | byte [] | buffer
| ) |  |

Callback to send received message to upper level

## Write()

static void monitor.Client.Write | ( | string | mes | ) |

static

Write a string to server

Returns
  Nothing

Parameters

  mes | Message to send to server

Definition at line 219 of file Client.cs.

## Member Data Documentation

## buffer

byte [] monitor.Client.buffer = new byte[BufferMaxSize]

staticprivate

Internal buffer used when reading data from server

Definition at line 61 of file Client.cs.

## BufferMaxSize

const int monitor.Client.BufferMaxSize = 512

private

Size of internal buffer used when reading data from server

Definition at line 56 of file Client.cs.

## client

TcpClient monitor.Client.client = null

staticprivate

Tcp client object

Definition at line 46 of file Client.cs.

## defaultIP

const string monitor.Client.defaultIP = "localhost"

Default server name

Definition at line 36 of file Client.cs.

## defaultPort

const int monitor.Client.defaultPort = 4500

Default server port number

Definition at line 41 of file Client.cs.

## initialReceiveBufferIndex

int monitor.Client.initialReceiveBufferIndex = 0

staticprivate

Definition at line 69 of file Client.cs.

## message

StringBuilder monitor.Client.message = new StringBuilder()

staticprivate

String containing received message from tcp server

Definition at line 74 of file Client.cs.

## newLength

int monitor.Client.newLength = 1

staticprivate

Definition at line 75 of file Client.cs.

## packetCounter

int monitor.Client.packetCounter = 0

staticprivate

Definition at line 76 of file Client.cs.

## readEvent

ReadEvent monitor.Client.readEvent = null

static

Definition at line 82 of file Client.cs.

## receiveBuffer

byte [] monitor.Client.receiveBuffer

staticprivate

buffer containing received message from TCP server Used to concatenate internal buffers into one

Definition at line 67 of file Client.cs.

## stream

NetworkStream monitor.Client.stream = null

staticprivate

Stream object used for communication

Definition at line 51 of file Client.cs.

The documentation for this class was generated from the following file:

- Client.cs