33 lines
1002 B
C++
33 lines
1002 B
C++
/**************************************************************************************************************
|
|
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
|
File Name : common_socket.h
|
|
Description: Privide Definition of class
|
|
Author : Yaming Wang
|
|
Version : 1.0
|
|
Data : 2019-11-3
|
|
History :
|
|
***************************************************************************************************************/
|
|
#ifndef DKAM_COMMON_SOCKET_H
|
|
#define DKAM_COMMON_SOCKET_H
|
|
#ifdef _WIN32
|
|
#include <winsock2.h>
|
|
#else
|
|
#include <netinet/in.h>
|
|
#include <sys/select.h>
|
|
#endif
|
|
|
|
|
|
class CommonSocket {
|
|
public:
|
|
CommonSocket();
|
|
~CommonSocket();
|
|
int InitSocket();
|
|
int Bind(int socket_fd, unsigned int ip, unsigned short port);
|
|
int Send(int socket_fd, unsigned int ip, unsigned short port, const char* buffer, unsigned int buffer_len);
|
|
int Receive(int socket_fd, char* buffer, int buffer_len);
|
|
int Select(int socket_fd, fd_set *rd_fds, fd_set *wd_fds);
|
|
};
|
|
|
|
|
|
#endif //!DKAM_COMMON_SOCKET_H
|