00001 /*========================================================================= 00002 00003 Program: Open IGT Link Library 00004 Module: $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink/Source/igtlServerSocket.h $ 00005 Language: C++ 00006 Date: $Date: 2010-06-09 16:16:36 -0400 (Wed, 09 Jun 2010) $ 00007 Version: $Revision: 6525 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notices for more information. 00014 00015 =========================================================================*/ 00016 /*========================================================================= 00017 00018 Program: Visualization Toolkit 00019 Module: $RCSfile: vtkServerSocket.h,v $ 00020 00021 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00022 All rights reserved. 00023 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00024 00025 This software is distributed WITHOUT ANY WARRANTY; without even 00026 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00027 PURPOSE. See the above copyright notice for more information. 00028 00029 =========================================================================*/ 00030 // .NAME igtlServerSocket - Encapsulate a socket that accepts connections. 00031 // .SECTION Description 00032 // 00033 00034 #ifndef __igtlServerSocket_h 00035 #define __igtlServerSocket_h 00036 00037 #include "igtlSocket.h" 00038 #include "igtlClientSocket.h" 00039 #include "igtlWin32Header.h" 00040 00041 namespace igtl 00042 { 00043 00044 class IGTLCommon_EXPORT ServerSocket : public Socket 00045 { 00046 public: 00047 typedef ServerSocket Self; 00048 typedef Socket Superclass; 00049 typedef SmartPointer<Self> Pointer; 00050 typedef SmartPointer<const Self> ConstPointer; 00051 00052 igtlTypeMacro(igtl::ServerSocket, igtl::Socket); 00053 igtlNewMacro(igtl::ServerSocket); 00054 00055 // Description: 00056 // Creates a server socket at a given port and binds to it. 00057 // Returns -1 on error. 0 on success. 00058 int CreateServer(int port); 00059 00060 // Description: 00061 // Waits for a connection. When a connection is received 00062 // a new ClientSocket object is created and returned. 00063 // Returns NULL on timeout. 00064 //ClientSocket* WaitForConnection(unsigned long msec=0); 00065 ClientSocket::Pointer WaitForConnection(unsigned long msec=0); 00066 00067 // Description: 00068 // Returns the port on which the server is running. 00069 int GetServerPort(); 00070 protected: 00071 ServerSocket(); 00072 ~ServerSocket(); 00073 00074 void PrintSelf(std::ostream& os) const; 00075 00076 private: 00077 ServerSocket(const ServerSocket&); // Not implemented. 00078 void operator=(const ServerSocket&); // Not implemented. 00079 }; 00080 00081 } // end of igtl namespace 00082 00083 00084 #endif 00085 00086