Main MRPT website > C++ reference for MRPT 1.5.6
CServerTCPSocket_LIN.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/config.h>
13 
14 #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE)
15 
18 #include <mrpt/system.h>
19 
20 // Platform specific headers:
21 #include <sys/socket.h>
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <errno.h>
25 //#include <iostream>
26 #include <sys/types.h>
27 #include <sys/ioctl.h>
28 #include <netdb.h>
29 #include <arpa/inet.h>
30 #include <netinet/in.h>
31 #include <sys/socket.h>
32 
33 
34 using namespace mrpt;
35 using namespace mrpt::utils;
36 
37 /*---------------------------------------------------------------
38  Constructor
39  ---------------------------------------------------------------*/
41  unsigned short listenPort,
42  const std::string &IPaddress,
43  int maxConnectionsWaiting,
44  mrpt::utils::VerbosityLevel verbosityLevel
45  ) :
46  COutputLogger("CServerTCPSocket")
47 {
49  setVerbosityLevel(verbosityLevel);
50  setupSocket( listenPort, IPaddress, maxConnectionsWaiting );
52 }
53 
54 /*---------------------------------------------------------------
55  Destructor
56  ---------------------------------------------------------------*/
58 {
59  // Delete socket:
60  if (m_serverSock != -1)
61  close( m_serverSock );
62 }
63 
64 #endif // Linux
void setupSocket(unsigned short listenPort, const std::string &IPaddress, int maxConnectionsWaiting)
Common code called from the platform-dependant constructor.
CServerTCPSocket(unsigned short listenPort, const std::string &IPaddress=std::string("127.0.0.1"), int maxConnectionsWaiting=50, mrpt::utils::VerbosityLevel verbosityLevel=mrpt::utils::LVL_INFO)
Constructor that creates the socket, performs binding, and start listening mode.
virtual ~CServerTCPSocket()
Dtor.
int m_serverSock
The handle for the listening server TCP socket.
#define MRPT_TRY_END
GLsizei const GLcharARB ** string
Definition: glew.h:3293
#define MRPT_TRY_START



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018