Public Member Functions
Construction and Destruction
|TcpServerDevice (const uint16 port)|
|virtual int32||open (void *arg)|
|virtual int32||close ()|
|virtual int32||read (uint8 *buffer, const int32 count)|
|virtual int32||write (uint8 *buffer, const int32 count)|
|virtual int32||ioCtl (uint32 cmd, void *arg)|
|virtual int32||seek (uint32 offset, SeekWhenceEnum whence)|
|virtual void||flush ()|
|char *||connect (struct timeval *timeout)|
Implements a TCP/IP server with a CharDevice interface. This enables the use of TCP sockets wherever a device is needed, e.g. for logging purposes. Due to the limited CharDevice abstraction, only basic features of sockets are available.
The TcpServerDevice can operate either in blocking or non-blocking mode. If used in blocking mode (default), open will block until the specified number of clients has connected. If used in non-blocking mode, the methods will never block. Data written to this device gets send to any clients that are connected at the moment. The operating mode can be switched with ioctl.
Constructs a new TcpServerDevice object. Stores the settings and tries to initialize the winsocket dll. Connections are not accepted yet, this will be done when the device is opened.
|port||TCP port this server listens to, e.g. 49152|
Destructs the object and releases all resources.
|virtual int32 ApparatusFramework::TcpServerDevice::close||(||)||
Closes the device, releases resources used for the operation. After another open, the device is ready for communication again.
|char* ApparatusFramework::TcpServerDevice::connect||(||struct timeval *||timeout||)|
Accepts a connection from a TCP client.
Closes the connection from a TCP client.
|virtual void ApparatusFramework::TcpServerDevice::flush||(||)||
Writes all internally buffered data onto the device and clears the send and receive buffers.
Universal method that may be used to configure the device and implement functionality not provided by the interface. The meaning of the different commands executed by this function is entirely device dependent (cmd 1 on device A may be something completely different on device B).
|cmd||A command that specifies the function to be executed by the method. Currently, only CHAR_DEVICE_SET_BLOCKING is supported.|
|arg||A pointer to an argument passed to the function to be executed|
|virtual int32 ApparatusFramework::TcpServerDevice::open||(||void *||arg||)||
Opens a character device. First method to be called after the instantiation. If this method returns successfully, the device is ready to use.
|arg||A void pointer that can be used for whatever one one choses (default = null).|
|virtual int32 ApparatusFramework::TcpServerDevice::read||(||uint8 *||buffer,|
Reads a specified number of characters from the device into a provided buffer. This read method for a device is usually implemented blocking (blocks the calling client).
|buffer||Pointer to a character buffer. Its the buffer that read will use to fill in the fetched data.|
|count||Number of characters to be read (does not necessarily correspond with the return value).|
|virtual int32 ApparatusFramework::TcpServerDevice::seek||(||uint32||offset,|
Allows to jump onto a certain position. Seek uses an offset that specifies the location from a certain starting point. (e.g. used in files to write onto a specified position). seek may also be used to find the size of a file (return value of seek(0, SEEK_END)).
|offset||A number that specifies the amount of chars the wanted position is away from a given starting position (whence defines that).|
|whence||Defines the starting position or how the given index should be interpreted.
|virtual int32 ApparatusFramework::TcpServerDevice::write||(||uint8 *||buffer,|
Writes a specified number of characters from a buffer onto the device.
|buffer||Pointer to a character buffer. Its the buffer that write takes as data source.|
|count||Number of characters to be taken out of the buffer onto the device.|
© 2004-2010 bbv Software Services AG / Apparatus Services