[DEV/API] change .h in .hpp
This commit is contained in:
parent
1571338fde
commit
975c124bd4
@ -4,6 +4,6 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Ftp.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Ftp.hpp>
|
||||
#include <string.h>
|
||||
|
@ -4,10 +4,10 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Http.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <map>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include <ethread/tools.h>
|
||||
#include <ethread/tools.hpp>
|
||||
|
||||
namespace enet {
|
||||
enum class HTTPAnswerCode {
|
46
enet/Tcp.cpp
46
enet/Tcp.cpp
@ -4,19 +4,22 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <sys/types.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <sys/types.hpp>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
#ifndef __TARGET_OS__Windows
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
bool enet::Tcp::setTCPNoDelay(bool _enabled) {
|
||||
@ -42,13 +45,11 @@ enet::Tcp::Tcp(int32_t _idSocket, const std::string& _name) :
|
||||
m_socketId(_idSocket),
|
||||
m_name(_name),
|
||||
m_status(status::link) {
|
||||
#if 1
|
||||
//Initialize the pollfd structure
|
||||
memset(m_fds, 0 , sizeof(m_fds));
|
||||
//Set up the initial listening socket
|
||||
m_fds[0].fd = _idSocket;
|
||||
m_fds[0].events = POLLIN | POLLERR;
|
||||
#endif
|
||||
//Initialize the pollfd structure
|
||||
memset(m_fds[0], 0 , sizeof(m_fds));
|
||||
//Set up the initial listening socket
|
||||
m_fds[0].fd = _idSocket;
|
||||
m_fds[0].events = POLLIN | POLLERR;
|
||||
}
|
||||
|
||||
enet::Tcp::Tcp(Tcp&& _obj) :
|
||||
@ -59,10 +60,9 @@ enet::Tcp::Tcp(Tcp&& _obj) :
|
||||
_obj.m_name = "";
|
||||
_obj.m_status = status::error;
|
||||
m_fds[0] = _obj.m_fds[0];
|
||||
#if 1
|
||||
memset(_obj.m_fds, 0 , sizeof(_obj.m_fds));
|
||||
#endif
|
||||
memset(m_fds[0], 0 , sizeof(m_fds));
|
||||
}
|
||||
|
||||
enet::Tcp::~Tcp() {
|
||||
unlink();
|
||||
}
|
||||
@ -76,9 +76,7 @@ enet::Tcp& enet::Tcp::operator = (enet::Tcp&& _obj) {
|
||||
m_status = _obj.m_status;
|
||||
_obj.m_status = status::error;
|
||||
m_fds[0] = _obj.m_fds[0];
|
||||
#if 1
|
||||
memset(_obj.m_fds, 0 , sizeof(_obj.m_fds));
|
||||
#endif
|
||||
memset(m_fds[0], 0 , sizeof(m_fds));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -86,7 +84,11 @@ bool enet::Tcp::unlink() {
|
||||
if (m_socketId >= 0) {
|
||||
ENET_INFO("Close socket (start)");
|
||||
shutdown(m_socketId, SHUT_RDWR);
|
||||
close(m_socketId);
|
||||
#ifdef __TARGET_OS__Windows
|
||||
closesocket(m_socketId);
|
||||
#else
|
||||
close(m_socketId);
|
||||
#endif
|
||||
ENET_INFO("Close socket (done)");
|
||||
m_socketId = -1;
|
||||
}
|
||||
|
@ -5,18 +5,27 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <mutex>
|
||||
#ifndef __TARGET_OS__Windows
|
||||
#include <poll.h>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
namespace enet {
|
||||
class Tcp {
|
||||
private:
|
||||
int32_t m_socketId; //!< socket linux interface generic
|
||||
#ifdef __TARGET_OS__Windows
|
||||
SOCKET m_socketId; //!< socket Windows interface generic
|
||||
#else
|
||||
int32_t m_socketId; //!< socket linux interface generic
|
||||
#endif
|
||||
#ifndef __TARGET_OS__Windows
|
||||
struct pollfd m_fds[1];
|
||||
int32_t m_fds[1];
|
||||
#else
|
||||
struct pollfd m_fds[1];
|
||||
#endif
|
||||
std::mutex m_mutex;
|
||||
public:
|
@ -4,18 +4,22 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/TcpClient.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8_t _ip4, uint16_t _port, uint32_t _numberRetry) {
|
||||
std::string tmpname;
|
||||
@ -59,7 +63,11 @@ enet::Tcp enet::connectTcpClient(const std::string& _hostname, uint16_t _port, u
|
||||
&& errno != ECONNREFUSED) {
|
||||
ENET_ERROR("ERROR connecting on : errno=" << errno << "," << strerror(errno));
|
||||
}
|
||||
close(socketId);
|
||||
#ifdef __TARGET_OS__Windows
|
||||
closesocket(socketId);
|
||||
#else
|
||||
close(socketId);
|
||||
#endif
|
||||
socketId = -1;
|
||||
}
|
||||
ENET_ERROR("ERROR connecting, maybe retry ... errno=" << errno << "," << strerror(errno));
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Tcp.hpp>
|
||||
|
||||
namespace enet {
|
||||
enet::Tcp connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8_t _ip4, uint16_t _port, uint32_t _numberRetry=5);
|
@ -4,17 +4,18 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/TcpServer.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
#ifdef __TARGET_OS__Windows
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
//https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms737889(v=vs.85).aspx
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
@ -83,7 +84,11 @@ bool enet::TcpServer::link() {
|
||||
ENET_INFO("Start binding Socket ... (can take some time ...)");
|
||||
if (bind(m_socketId, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) {
|
||||
ENET_ERROR("ERROR on binding errno=" << errno << "," << strerror(errno));
|
||||
close(m_socketId);
|
||||
#ifdef __TARGET_OS__Windows
|
||||
closesocket(m_socketId);
|
||||
#else
|
||||
close(m_socketId);
|
||||
#endif
|
||||
m_socketId = -1;
|
||||
return false;
|
||||
}
|
||||
@ -99,7 +104,11 @@ enet::Tcp enet::TcpServer::waitNext() {
|
||||
int32_t socketIdClient = accept(m_socketId, (struct sockaddr *) &clientAddr, &clilen);
|
||||
if (socketIdClient < 0) {
|
||||
ENET_ERROR("ERROR on accept errno=" << errno << "," << strerror(errno));
|
||||
close(m_socketId);
|
||||
#ifdef __TARGET_OS__Windows
|
||||
closesocket(m_socketId);
|
||||
#else
|
||||
close(m_socketId);
|
||||
#endif
|
||||
m_socketId = -1;
|
||||
return enet::Tcp();
|
||||
}
|
||||
@ -111,7 +120,11 @@ enet::Tcp enet::TcpServer::waitNext() {
|
||||
bool enet::TcpServer::unlink() {
|
||||
if (m_socketId >= 0) {
|
||||
ENET_INFO(" close server socket");
|
||||
close(m_socketId);
|
||||
#ifdef __TARGET_OS__Windows
|
||||
closesocket(m_socketId);
|
||||
#else
|
||||
close(m_socketId);
|
||||
#endif
|
||||
m_socketId = -1;
|
||||
}
|
||||
return true;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Tcp.hpp>
|
||||
#ifdef __TARGET_OS__Windows
|
||||
|
||||
#else
|
||||
@ -14,7 +14,11 @@
|
||||
namespace enet {
|
||||
class TcpServer {
|
||||
private:
|
||||
int32_t m_socketId; //!< socket linux interface generic
|
||||
#ifdef __TARGET_OS__Windows
|
||||
SOCKET m_socketId; //!< socket Windows interface generic
|
||||
#else
|
||||
int32_t m_socketId; //!< socket linux interface generic
|
||||
#endif
|
||||
#ifndef __TARGET_OS__Windows
|
||||
struct pollfd m_fds[1];
|
||||
#endif
|
@ -4,6 +4,6 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/Udp.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/Udp.hpp>
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/WebSocket.h>
|
||||
#include <enet/debug.hpp>
|
||||
#include <enet/WebSocket.hpp>
|
||||
#include <map>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <string.h>
|
||||
#include <random>
|
||||
#include <algue/base64.h>
|
||||
#include <algue/sha1.h>
|
||||
#include <algue/base64.hpp>
|
||||
#include <algue/sha1.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <enet/Http.h>
|
||||
#include <ememory/memory.h>
|
||||
#include <enet/Http.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <enet/debug.h>
|
||||
#include <enet/debug.hpp>
|
||||
|
||||
int32_t enet::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("enet");
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace enet {
|
||||
int32_t getLogId();
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <enet/Udp.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Http.h>
|
||||
#include <enet/Ftp.h>
|
||||
#include <enet/Udp.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/Ftp.hpp>
|
||||
|
||||
|
||||
/**
|
@ -43,14 +43,14 @@ def create(target, module_name):
|
||||
'enet/WebSocket.cpp',
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'enet/debug.h',
|
||||
'enet/Udp.h',
|
||||
'enet/Tcp.h',
|
||||
'enet/TcpServer.h',
|
||||
'enet/TcpClient.h',
|
||||
'enet/Http.h',
|
||||
'enet/Ftp.h',
|
||||
'enet/WebSocket.h',
|
||||
'enet/debug.hpp',
|
||||
'enet/Udp.hpp',
|
||||
'enet/Tcp.hpp',
|
||||
'enet/TcpServer.hpp',
|
||||
'enet/TcpClient.hpp',
|
||||
'enet/Http.hpp',
|
||||
'enet/Ftp.hpp',
|
||||
'enet/WebSocket.hpp',
|
||||
])
|
||||
return my_module
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/TcpClient.h>
|
||||
#include <enet/Http.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace appl {
|
||||
|
@ -4,14 +4,14 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/TcpClient.h>
|
||||
#include <enet/Http.h>
|
||||
#include <enet/WebSocket.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/WebSocket.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace appl {
|
||||
|
@ -4,13 +4,13 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/TcpClient.h>
|
||||
#include <enet/Http.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
|
@ -4,14 +4,14 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Http.h>
|
||||
#include <enet/TcpServer.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <unistd.hpp>
|
||||
#include <etk/stdTools.hpp>
|
||||
namespace appl {
|
||||
void onReceiveData(enet::HttpServer* _interface, std::vector<uint8_t>& _data) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
|
@ -4,15 +4,15 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Http.h>
|
||||
#include <enet/WebSocket.h>
|
||||
#include <enet/TcpServer.h>
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/WebSocket.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
namespace appl {
|
||||
void onReceiveData(enet::WebSocket* _interface, std::vector<uint8_t>& _data, bool _isString) {
|
||||
TEST_INFO("Receive Datas : " << _data.size() << " bytes");
|
||||
|
@ -4,13 +4,13 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <enet/Tcp.h>
|
||||
#include <enet/Http.h>
|
||||
#include <etk/etk.h>
|
||||
#include <enet/TcpServer.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user