YDLIDAR SDK  V1.3.6
Public Member Functions | List of all members
ydlidar::CPassiveSocket Class Reference
Inheritance diagram for ydlidar::CPassiveSocket:
Inheritance graph
[legend]
Collaboration diagram for ydlidar::CPassiveSocket:
Collaboration graph
[legend]

Public Member Functions

 CPassiveSocket (CSocketType type=SocketTypeTcp)
 
virtual CActiveSocketAccept (void)
 
bool BindMulticast (const char *pInterface, const char *pGroup, uint16_t nPort)
 
virtual bool Listen (const char *pAddr, uint16_t nPort, int32_t nConnectionBacklog=30000)
 
virtual int32_t Send (const uint8_t *pBuf, size_t bytesToSend)
 
- Public Member Functions inherited from ydlidar::CSimpleSocket
 CSimpleSocket (CSocketType type=SocketTypeTcp)
 
 CSimpleSocket (CSimpleSocket &socket)
 
virtual bool Initialize (void)
 
virtual bool Close (void)
 
virtual bool Shutdown (CShutdownMode nShutdown)
 
virtual bool Select (void)
 
virtual bool Select (int32_t nTimeoutSec, int32_t nTimeoutUSec)
 
virtual int WaitForData (size_t data_count, uint32_t timeout, size_t *returned_size)
 
virtual bool IsSocketValid (void)
 
void TranslateSocketError (void)
 
const char * DescribeError ()
 
virtual int32_t Receive (int32_t nMaxBytes=1, uint8_t *pBuffer=0)
 
virtual int32_t Send (const struct iovec *sendVector, int32_t nNumItems)
 
virtual int32_t SendFile (int32_t nOutFd, int32_t nInFd, off_t *pOffset, int32_t nCount)
 
bool IsNonblocking (void)
 
bool SetBlocking (void)
 
bool SetNonblocking (void)
 
uint8_t * GetData (void)
 
int32_t GetBytesReceived (void)
 
int32_t GetBytesSent (void)
 
bool SetOptionLinger (bool bEnable, uint16_t nTime)
 
bool SetOptionReuseAddr ()
 
int32_t GetConnectTimeoutSec (void)
 
int32_t GetConnectTimeoutUSec (void)
 
void SetConnectTimeout (int32_t nConnectTimeoutSec, int32_t nConnectTimeoutUsec=0)
 
int32_t GetReceiveTimeoutSec (void)
 
int32_t GetReceiveTimeoutUSec (void)
 
bool SetReceiveTimeout (int32_t nRecvTimeoutSec, int32_t nRecvTimeoutUsec=0)
 
bool SetMulticast (bool bEnable, uint8_t multicastTTL=1)
 
bool GetMulticast ()
 
bool BindInterface (const char *pInterface)
 
int32_t GetSendTimeoutSec (void)
 
int32_t GetSendTimeoutUSec (void)
 
bool SetSendTimeout (int32_t nSendTimeoutSec, int32_t nSendTimeoutUsec=0)
 
CSocketError GetSocketError (void)
 
uint32_t GetTotalTimeMs ()
 
uint32_t GetTotalTimeUsec ()
 
int GetSocketDscp (void)
 
bool SetSocketDscp (int nDscp)
 
SOCKET GetSocketDescriptor ()
 
CSocketType GetSocketType ()
 
void SetSocketType (const CSocketType &type)
 set socket descriptor
 
const char * GetClientAddr ()
 
uint16_t GetClientPort ()
 
const char * GetServerAddr ()
 
uint16_t GetServerPort ()
 
uint32_t GetReceiveWindowSize ()
 
uint32_t GetSendWindowSize ()
 
uint32_t SetReceiveWindowSize (uint32_t nWindowSize)
 
uint32_t SetSendWindowSize (uint32_t nWindowSize)
 
bool DisableNagleAlgoritm ()
 
bool EnableNagleAlgoritm ()
 
virtual bool Open (const char *pAddr, uint16_t nPort)
 
virtual bool bindport (const char *, uint32_t)
 
virtual bool open ()
 
virtual bool isOpen ()
 
virtual void closePort ()
 
virtual void flush ()
 
virtual int waitfordata (size_t data_count, uint32_t timeout=-1, size_t *returned_size=NULL)
 
virtual size_t writeData (const uint8_t *data, size_t size)
 
virtual size_t readData (uint8_t *data, size_t size)
 
- Public Member Functions inherited from ChannelDevice
virtual bool setDTR (bool level=true)
 
virtual int getByteTime ()
 
virtual void ReleasePort ()
 

Additional Inherited Members

- Public Types inherited from ydlidar::CSimpleSocket
enum  CShutdownMode { Receives = SHUT_RD, Sends = SHUT_WR, Both = SHUT_RDWR }
 Defines the three possible states for shuting down a socket. More...
 
enum  CSocketType {
  SocketTypeInvalid = 0, SocketTypeTcp, SocketTypeUdp, SocketTypeTcp6,
  SocketTypeUdp6, SocketTypeRaw
}
 Defines the socket types defined by CSimpleSocket class. More...
 
enum  CSocketError {
  SocketError = -1, SocketSuccess = 0, SocketInvalidSocket, SocketInvalidAddress,
  SocketInvalidPort, SocketConnectionRefused, SocketTimedout, SocketEwouldblock,
  SocketNotconnected, SocketEinprogress, SocketInterrupted, SocketConnectionAborted,
  SocketProtocolError, SocketFirewallError, SocketInvalidSocketBuffer, SocketConnectionReset,
  SocketAddressInUse, SocketInvalidPointer, SocketEunknown
}
 Defines all error codes handled by the CSimpleSocket class. More...
 
- Static Public Member Functions inherited from ydlidar::CSimpleSocket
static const char * DescribeError (CSocketError err)
 
- Protected Member Functions inherited from ydlidar::CSimpleSocket
void SetSocketError (CSimpleSocket::CSocketError error)
 
void SetSocketHandle (SOCKET socket)
 
bool Flush ()
 
- Protected Attributes inherited from ydlidar::CSimpleSocket
SOCKET m_socket
 
CSocketError m_socketErrno
 socket handle
 
uint8_t * m_pBuffer
 number of last error
 
int32_t m_nBufferSize
 internal send/receive buffer
 
int32_t m_nSocketDomain
 size of internal send/receive buffer
 
CSocketType m_nSocketType
 socket type PF_INET, PF_INET6
 
int32_t m_nBytesReceived
 socket type - UDP, TCP or RAW
 
int32_t m_nBytesSent
 number of bytes received
 
uint32_t m_nFlags
 number of bytes sent
 
bool m_bIsBlocking
 socket flags
 
bool m_bIsMulticast
 is socket blocking
 
struct timeval m_stConnectTimeout
 is the UDP socket multicast;
 
struct timeval m_stRecvTimeout
 connection timeout
 
struct timeval m_stSendTimeout
 receive timeout
 
struct sockaddr_in m_stServerSockaddr
 send timeout
 
struct sockaddr_in m_stClientSockaddr
 server address
 
struct sockaddr_in m_stMulticastGroup
 client address
 
struct linger m_stLinger
 multicast group to bind to
 
CStatTimer m_timer
 linger flag
 
fd_set m_writeFds
 internal statistics.
 
fd_set m_readFds
 write file descriptor set
 
fd_set m_errorFds
 read file descriptor set
 
std::string m_addr
 error file descriptor set
 
uint32_t m_port
 
bool m_open
 

Member Function Documentation

CActiveSocket * CPassiveSocket::Accept ( void  )
virtual

Extracts the first connection request on the queue of pending connections and creates a newly connected socket. Used with CSocketType CSimpleSocket::SocketTypeTcp. It is the responsibility of the caller to delete the returned object when finished.

Returns
if successful a pointer to a newly created CActiveSocket object will be returned and the internal error condition of the CPassiveSocket object will be CPassiveSocket::SocketSuccess. If an error condition was encountered the NULL will be returned and one of the following error conditions will be set: CPassiveSocket::SocketEwouldblock, CPassiveSocket::SocketInvalidSocket, CPassiveSocket::SocketConnectionAborted, CPassiveSocket::SocketInterrupted CPassiveSocket::SocketProtocolError, CPassiveSocket::SocketFirewallError
bool CPassiveSocket::BindMulticast ( const char *  pInterface,
const char *  pGroup,
uint16_t  nPort 
)

Bind to a multicast group on a specified interface, multicast group, and port

Parameters
pInterface- interface on which to bind.
pGroup- multicast group address to bind.
nPort- port on which multicast
Returns
true if able to bind to interface and multicast group. If not successful, the false is returned and one of the following error condiitions will be set: CPassiveSocket::SocketAddressInUse, CPassiveSocket::SocketProtocolError, CPassiveSocket::SocketInvalidSocket. The following socket errors are for Linux/Unix derived systems only: CPassiveSocket::SocketInvalidSocketBuffer
bool CPassiveSocket::Listen ( const char *  pAddr,
uint16_t  nPort,
int32_t  nConnectionBacklog = 30000 
)
virtual

Create a listening socket at local ip address 'x.x.x.x' or 'localhost' if pAddr is NULL on port nPort.

Parameters
pAddrspecifies the IP address on which to listen.
nPortspecifies the port on which to listen.
nConnectionBacklogspecifies connection queue backlog (default 30,000)
Returns
true if a listening socket was created. If not successful, the false is returned and one of the following error conditions will be set: CPassiveSocket::SocketAddressInUse, CPassiveSocket::SocketProtocolError, CPassiveSocket::SocketInvalidSocket. The following socket errors are for Linux/Unix derived systems only: CPassiveSocket::SocketInvalidSocketBuffer
int32_t CPassiveSocket::Send ( const uint8_t *  pBuf,
size_t  bytesToSend 
)
virtual

Attempts to send a block of data on an established connection.

Parameters
pBufblock of data to be sent.
bytesToSendsize of data block to be sent.
Returns
number of bytes actually sent, return of zero means the connection has been shutdown on the other side, and a return of -1 means that an error has occurred. If an error was signaled then one of the following error codes will be set: CPassiveSocket::SocketInvalidSocket, CPassiveSocket::SocketEwouldblock, SimpleSocket::SocketConnectionReset, CPassiveSocket::SocketInvalidSocketBuffer, CPassiveSocket::SocketInterrupted, CPassiveSocket::SocketProtocolError, CPassiveSocket::SocketNotconnected
Note: This function is used only for a socket of type CSimpleSocket::SocketTypeUdp

Reimplemented from ydlidar::CSimpleSocket.


The documentation for this class was generated from the following files: