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 "vtkObject.h"
26 
29 {
30 public:
31  vtkTypeMacro(vtkSocket, vtkObject);
32  void PrintSelf(ostream& os, vtkIndent indent);
33 
34  // ----- Status API ----
36  int GetConnected() { return (this->SocketDescriptor >=0); }
37 
39  void CloseSocket();
40 
41  // ------ Communication API ---
44  int Send(const void* data, int length);
45 
51  int Receive(void* data, int length, int readFully=1);
52 
54 
56  vtkGetMacro(SocketDescriptor, int);
58 
60 
62  static int SelectSockets(const int* sockets_to_select, int size,
63  unsigned long msec, int* selected_index);
64 protected:
65  vtkSocket();
66  ~vtkSocket();
68 
70 
71  //BTX
72  friend class vtkSocketCollection;
73  //ETX
74 
77  int CreateSocket();
78 
80  void CloseSocket(int socketdescriptor);
81 
84  int BindSocket(int socketdescriptor, int port);
85 
88  int SelectSocket(int socketdescriptor, unsigned long msec);
89 
92  int Accept(int socketdescriptor);
93 
96  int Listen(int socketdescriptor);
97 
99  int Connect(int socketdescriptor, const char* hostname, int port);
100 
102  int GetPort(int socketdescriptor);
103 
104 private:
105  vtkSocket(const vtkSocket&); // Not implemented.
106  void operator=(const vtkSocket&); // Not implemented.
107 };
108 
109 
110 #endif
111 
abstract base class for most VTK objects
Definition: vtkObject.h:60
a collection for sockets.
int SocketDescriptor
Definition: vtkSocket.h:69
int GetConnected()
Definition: vtkSocket.h:36
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
#define VTK_COMMON_EXPORT
BSD socket encapsulation.
Definition: vtkSocket.h:28