00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00022 #ifndef __vtkSocket_h
00023 #define __vtkSocket_h
00024
00025 #include "vtkObject.h"
00026
00027 class vtkSocketCollection;
00028 class VTK_COMMON_EXPORT vtkSocket : public vtkObject
00029 {
00030 public:
00031 vtkTypeRevisionMacro(vtkSocket, vtkObject);
00032 void PrintSelf(ostream& os, vtkIndent indent);
00033
00034
00036 int GetConnected() { return (this->SocketDescriptor >=0); }
00037
00039 void CloseSocket() {this->CloseSocket(this->SocketDescriptor);}
00040
00041
00044 int Send(const void* data, int length);
00045
00051 int Receive(void* data, int length, int readFully=1);
00052
00053 protected:
00054 vtkSocket();
00055 ~vtkSocket();
00056
00057 int SocketDescriptor;
00058 vtkGetMacro(SocketDescriptor, int);
00059
00060
00061 friend class vtkSocketCollection;
00062
00063
00066 int CreateSocket();
00067
00069 void CloseSocket(int socketdescriptor);
00070
00073 int BindSocket(int socketdescriptor, int port);
00074
00077 int SelectSocket(int socketdescriptor, unsigned long msec);
00078
00081 int Accept(int socketdescriptor);
00082
00085 int Listen(int socketdescriptor);
00086
00088 int Connect(int socketdescriptor, const char* hostname, int port);
00089
00091 int GetPort(int socketdescriptor);
00092
00094
00096 static int SelectSockets(const int* sockets_to_select, int size,
00097 unsigned long msec, int* selected_index);
00099 private:
00100 vtkSocket(const vtkSocket&);
00101 void operator=(const vtkSocket&);
00102 };
00103
00104
00105 #endif
00106