VTK
dox/Common/System/vtkSocket.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSocket.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00022 #ifndef __vtkSocket_h
00023 #define __vtkSocket_h
00024 
00025 #include "vtkCommonSystemModule.h" // For export macro
00026 #include "vtkObject.h"
00027 
00028 class vtkSocketCollection;
00029 class VTKCOMMONSYSTEM_EXPORT vtkSocket : public vtkObject
00030 {
00031 public:
00032   vtkTypeMacro(vtkSocket, vtkObject);
00033   void PrintSelf(ostream& os, vtkIndent indent);
00034 
00035   // ----- Status API ----
00037   int GetConnected() { return (this->SocketDescriptor >=0); }
00038 
00040   void CloseSocket();
00041 
00042   // ------ Communication API ---
00045   int Send(const void* data, int length);
00046 
00052   int Receive(void* data, int length, int readFully=1);
00053 
00055 
00057   vtkGetMacro(SocketDescriptor, int);
00059 
00061 
00063   static int SelectSockets(const int* sockets_to_select, int size,
00064     unsigned long msec, int* selected_index);
00065 protected:
00066   vtkSocket();
00067   ~vtkSocket();
00069 
00070   int SocketDescriptor;
00071 
00072   //BTX
00073   friend class vtkSocketCollection;
00074   //ETX
00075 
00078   int CreateSocket();
00079 
00081   void CloseSocket(int socketdescriptor);
00082 
00085   int BindSocket(int socketdescriptor, int port);
00086 
00089   int SelectSocket(int socketdescriptor, unsigned long msec);
00090 
00093   int Accept(int socketdescriptor);
00094 
00097   int Listen(int socketdescriptor);
00098 
00100   int Connect(int socketdescriptor, const char* hostname, int port);
00101 
00103   int GetPort(int socketdescriptor);
00104 
00105 private:
00106   vtkSocket(const vtkSocket&); // Not implemented.
00107   void operator=(const vtkSocket&); // Not implemented.
00108 };
00109 
00110 
00111 #endif
00112