YDLIDAR SDK  V1.3.6
PassiveSocket.h
1 /*---------------------------------------------------------------------------*/
2 /* */
3 /* Socket.h - Passive Socket Decleration. */
4 /* */
5 /* Author : Mark Carrier (mark@carrierlabs.com) */
6 /* */
7 /*---------------------------------------------------------------------------*/
8 /* Copyright (c) 2007-2009 CarrierLabs, LLC. All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * 1. Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  *
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in
19  * the documentation and/or other materials provided with the
20  * distribution.
21  *
22  * 3. The name of the author may not be used to endorse or promote products
23  * derived from this software without specific prior written permission.
24  *
25  * 4. The name "CarrierLabs" must not be used to
26  * endorse or promote products derived from this software without
27  * prior written permission. For written permission, please contact
28  * mark@carrierlabs.com.
29  *
30  * THIS SOFTWARE IS PROVIDED BY MARK CARRIER ``AS IS'' AND ANY
31  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MARK CARRIER OR
34  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
41  * OF THE POSSIBILITY OF SUCH DAMAGE.
42  *----------------------------------------------------------------------------*/
43 #ifndef __PASSIVESOCKET_H__
44 #define __PASSIVESOCKET_H__
45 #include "ActiveSocket.h"
46 
56 namespace ydlidar {
57 
58 class CPassiveSocket : public CSimpleSocket {
59 public:
60  explicit CPassiveSocket(CSocketType type = SocketTypeTcp);
61  virtual ~CPassiveSocket() {
62  Close();
63  };
64 
76  virtual CActiveSocket *Accept(void);
77 
88  bool BindMulticast(const char *pInterface, const char *pGroup, uint16_t nPort);
89 
101  virtual bool Listen(const char *pAddr, uint16_t nPort, int32_t nConnectionBacklog = 30000);
102 
115  virtual int32_t Send(const uint8_t *pBuf, size_t bytesToSend);
116 
117 private:
118  struct ip_mreq m_stMulticastRequest;
119 
120 };
121 
122 }
123 
124 #endif // __PASSIVESOCKET_H__
Definition: ActiveSocket.h:48
bool BindMulticast(const char *pInterface, const char *pGroup, uint16_t nPort)
Definition: PassiveSocket.cpp:52
CSocketType
Defines the socket types defined by CSimpleSocket class.
Definition: SimpleSocket.h:125
Definition: SimpleSocket.h:114
virtual CActiveSocket * Accept(void)
Definition: PassiveSocket.cpp:221
virtual bool Close(void)
Definition: SimpleSocket.cpp:490
Defines socket as TCP socket.
Definition: SimpleSocket.h:128
Definition: PassiveSocket.h:58
virtual int32_t Send(const uint8_t *pBuf, size_t bytesToSend)
Definition: PassiveSocket.cpp:295
virtual bool Listen(const char *pAddr, uint16_t nPort, int32_t nConnectionBacklog=30000)
Definition: PassiveSocket.cpp:134
Definition: ActiveSocket.h:56