VTK
vtkSocket.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSocket.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
22 #ifndef vtkSocket_h
23 #define vtkSocket_h
24 
25 #include "vtkCommonSystemModule.h" // For export macro
26 #include "vtkObject.h"
27 
30 {
31 public:
32  vtkTypeMacro(vtkSocket, vtkObject);
33  void PrintSelf(ostream& os, vtkIndent indent);
34 
35  // ----- Status API ----
37  int GetConnected() { return (this->SocketDescriptor >=0); }
38 
40  void CloseSocket();
41 
42  // ------ Communication API ---
45  int Send(const void* data, int length);
46 
52  int Receive(void* data, int length, int readFully=1);
53 
55 
57  vtkGetMacro(SocketDescriptor, int);
59 
61 
63  static int SelectSockets(const int* sockets_to_select, int size,
64  unsigned long msec, int* selected_index);
65 protected:
66  vtkSocket();
67  ~vtkSocket();
69 
71 
72  //BTX
73  friend class vtkSocketCollection;
74  //ETX
75 
78  int CreateSocket();
79 
81  void CloseSocket(int socketdescriptor);
82 
85  int BindSocket(int socketdescriptor, int port);
86 
89  int SelectSocket(int socketdescriptor, unsigned long msec);
90 
93  int Accept(int socketdescriptor);
94 
97  int Listen(int socketdescriptor);
98 
100  int Connect(int socketdescriptor, const char* hostname, int port);
101 
103  int GetPort(int socketdescriptor);
104 
105 private:
106  vtkSocket(const vtkSocket&); // Not implemented.
107  void operator=(const vtkSocket&); // Not implemented.
108 };
109 
110 
111 #endif
112 
abstract base class for most VTK objects
Definition: vtkObject.h:61
a collection for sockets.
int SocketDescriptor
Definition: vtkSocket.h:70
int GetConnected()
Definition: vtkSocket.h:37
#define VTKCOMMONSYSTEM_EXPORT
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
BSD socket encapsulation.
Definition: vtkSocket.h:29