VTK
|
BSD socket encapsulation. More...
#include <vtkSocket.h>
Public Types | |
typedef vtkObject | Superclass |
Public Member Functions | |
virtual const char * | GetClassName () |
virtual int | IsA (const char *type) |
void | PrintSelf (ostream &os, vtkIndent indent) |
int | GetConnected () |
void | CloseSocket () |
int | Send (const void *data, int length) |
int | Receive (void *data, int length, int readFully=1) |
virtual int | GetSocketDescriptor () |
Static Public Member Functions | |
static int | IsTypeOf (const char *type) |
static vtkSocket * | SafeDownCast (vtkObject *o) |
Protected Member Functions | |
int | CreateSocket () |
void | CloseSocket (int socketdescriptor) |
int | BindSocket (int socketdescriptor, int port) |
int | SelectSocket (int socketdescriptor, unsigned long msec) |
int | Accept (int socketdescriptor) |
int | Listen (int socketdescriptor) |
int | Connect (int socketdescriptor, const char *hostname, int port) |
int | GetPort (int socketdescriptor) |
Protected Attributes | |
int | SocketDescriptor |
Friends | |
class | vtkSocketCollection |
static int | SelectSockets (const int *sockets_to_select, int size, unsigned long msec, int *selected_index) |
vtkSocket () | |
~vtkSocket () |
BSD socket encapsulation.
This abstract class encapsulates a BSD socket. It provides an API for basic socket operations.
Definition at line 28 of file vtkSocket.h.
typedef vtkObject vtkSocket::Superclass |
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
Definition at line 31 of file vtkSocket.h.
vtkSocket::vtkSocket | ( | ) | [protected] |
Selects set of sockets. Returns 0 on timeout, -1 on error. 1 on success. Selected socket's index is returned thru selected_index
vtkSocket::~vtkSocket | ( | ) | [protected] |
Selects set of sockets. Returns 0 on timeout, -1 on error. 1 on success. Selected socket's index is returned thru selected_index
virtual const char* vtkSocket::GetClassName | ( | ) | [virtual] |
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
static int vtkSocket::IsTypeOf | ( | const char * | name | ) | [static] |
Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
virtual int vtkSocket::IsA | ( | const char * | name | ) | [virtual] |
Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
void vtkSocket::PrintSelf | ( | ostream & | os, |
vtkIndent | indent | ||
) | [virtual] |
Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from vtkObject.
Reimplemented in vtkServerSocket, and vtkClientSocket.
int vtkSocket::GetConnected | ( | ) | [inline] |
Check is the socket is alive.
Definition at line 36 of file vtkSocket.h.
void vtkSocket::CloseSocket | ( | ) |
Close the socket.
These methods send data over the socket. Returns 1 on success, 0 on error and raises vtkCommand::ErrorEvent.
Receive data from the socket. This call blocks until some data is read from the socket. When readFully is set, this call will block until all the requested data is read from the socket. 0 on error, else number of bytes read is returned. On error, vtkCommand::ErrorEvent is raised.
virtual int vtkSocket::GetSocketDescriptor | ( | ) | [virtual] |
Provides access to the internal socket descriptor. This is valid only when GetConnected() returns true.
static int vtkSocket::SelectSockets | ( | const int * | sockets_to_select, |
int | size, | ||
unsigned long | msec, | ||
int * | selected_index | ||
) | [static] |
Selects set of sockets. Returns 0 on timeout, -1 on error. 1 on success. Selected socket's index is returned thru selected_index
int vtkSocket::CreateSocket | ( | ) | [protected] |
Creates an endpoint for communication and returns the descriptor. -1 indicates error.
void vtkSocket::CloseSocket | ( | int | socketdescriptor | ) | [protected] |
Close the socket.
Binds socket to a particular port. Returns 0 on success other -1 is returned.
Selects a socket ie. waits for it to change status. Returns 1 on success; 0 on timeout; -1 on error. msec=0 implies no timeout.
Accept a connection on a socket. Returns -1 on error. Otherwise the descriptor of the accepted socket.
Listen for connections on a socket. Returns 0 on success. -1 on error.
Connect to a server socket. Returns 0 on success, -1 on error.
Returns the port to which the socket is connected. 0 on error.
friend class vtkSocketCollection [friend] |
Definition at line 72 of file vtkSocket.h.
int vtkSocket::SocketDescriptor [protected] |
Definition at line 69 of file vtkSocket.h.