[DEV] remove dependency of unistd.h
This commit is contained in:
parent
1d63f0188f
commit
6fa2ed2003
@ -9,7 +9,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static std::string escapeChar(const std::string& _value) {
|
static std::string escapeChar(const std::string& _value) {
|
||||||
return _value;
|
return _value;
|
||||||
@ -147,7 +147,7 @@ void enet::Http::start() {
|
|||||||
}
|
}
|
||||||
while ( m_threadRunning == true
|
while ( m_threadRunning == true
|
||||||
&& m_connection.getConnectionStatus() != enet::Tcp::status::link) {
|
&& m_connection.getConnectionStatus() != enet::Tcp::status::link) {
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
//ethread::setPriority(*m_receiveThread, -6);
|
//ethread::setPriority(*m_receiveThread, -6);
|
||||||
ENET_DEBUG("connect [STOP]");
|
ENET_DEBUG("connect [STOP]");
|
||||||
@ -364,7 +364,7 @@ void enet::Http::getHeader() {
|
|||||||
char type;
|
char type;
|
||||||
int32_t len = m_connection.read(&type, 1);
|
int32_t len = m_connection.read(&type, 1);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
usleep(1);
|
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
header += type;
|
header += type;
|
||||||
|
@ -46,7 +46,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
socketId = socket(AF_INET, SOCK_STREAM, 0);
|
socketId = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (socketId < 0) {
|
if (socketId < 0) {
|
||||||
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
|
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
|
||||||
usleep(200000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
||||||
@ -63,7 +63,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
int iResult = getaddrinfo(_hostname.c_str(), portValue.c_str(), &hints, &result);
|
int iResult = getaddrinfo(_hostname.c_str(), portValue.c_str(), &hints, &result);
|
||||||
if (iResult != 0) {
|
if (iResult != 0) {
|
||||||
ENET_ERROR("getaddrinfo failed with error: " << iResult);
|
ENET_ERROR("getaddrinfo failed with error: " << iResult);
|
||||||
usleep(200000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
|
|
||||||
if (socketId == INVALID_SOCKET) {
|
if (socketId == INVALID_SOCKET) {
|
||||||
ENET_ERROR("Unable to connect to server!");
|
ENET_ERROR("Unable to connect to server!");
|
||||||
usleep(200000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -119,7 +119,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
socketId = socket(AF_INET, SOCK_STREAM, 0);
|
socketId = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (socketId < 0) {
|
if (socketId < 0) {
|
||||||
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
|
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
|
||||||
usleep(200000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
ENET_INFO("Try connect on socket ... (" << iii+1 << "/" << _numberRetry << ")");
|
||||||
@ -127,7 +127,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
struct hostent* server = gethostbyname(_hostname.c_str());
|
struct hostent* server = gethostbyname(_hostname.c_str());
|
||||||
if (server == nullptr) {
|
if (server == nullptr) {
|
||||||
ENET_ERROR("ERROR, no such host : " << _hostname);
|
ENET_ERROR("ERROR, no such host : " << _hostname);
|
||||||
usleep(200000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bzero((char *) &servAddr, sizeof(servAddr));
|
bzero((char *) &servAddr, sizeof(servAddr));
|
||||||
@ -150,7 +150,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
|
|||||||
socketId = -1;
|
socketId = -1;
|
||||||
}
|
}
|
||||||
ENET_ERROR("ERROR connecting, maybe retry ... errno=" << errno << "," << strerror(errno));
|
ENET_ERROR("ERROR connecting, maybe retry ... errno=" << errno << "," << strerror(errno));
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if we are here ==> then the connextion is done corectly ...
|
// if we are here ==> then the connextion is done corectly ...
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include <algue/base64.hpp>
|
#include <algue/base64.hpp>
|
||||||
#include <algue/sha1.hpp>
|
#include <algue/sha1.hpp>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace enet {
|
namespace enet {
|
||||||
@ -148,7 +148,7 @@ void enet::WebSocket::start(const std::string& _uri, const std::vector<std::stri
|
|||||||
|| m_interface->isAlive() == false) {
|
|| m_interface->isAlive() == false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
timeout--;
|
timeout--;
|
||||||
}
|
}
|
||||||
if ( m_connectionValidate == false
|
if ( m_connectionValidate == false
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <etk/etk.hpp>
|
#include <etk/etk.hpp>
|
||||||
|
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
void onReceiveData(std::vector<uint8_t>& _data) {
|
void onReceiveData(std::vector<uint8_t>& _data) {
|
||||||
@ -53,7 +53,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
connection.setHeader(req);
|
connection.setHeader(req);
|
||||||
|
|
||||||
while (connection.isAlive() == true) {
|
while (connection.isAlive() == true) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <etk/etk.hpp>
|
#include <etk/etk.hpp>
|
||||||
|
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
void onReceiveData(std::vector<uint8_t>& _data, bool _isString) {
|
void onReceiveData(std::vector<uint8_t>& _data, bool _isString) {
|
||||||
@ -66,7 +66,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
int32_t timeout = 20;
|
int32_t timeout = 20;
|
||||||
while (connection.isAlive() == true
|
while (connection.isAlive() == true
|
||||||
&& timeout > 0) {
|
&& timeout > 0) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
timeout--;
|
timeout--;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <enet/TcpServer.hpp>
|
#include <enet/TcpServer.hpp>
|
||||||
#include <etk/etk.hpp>
|
#include <etk/etk.hpp>
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
namespace appl {
|
namespace appl {
|
||||||
void onReceiveData(enet::HttpServer* _interface, std::vector<uint8_t>& _data) {
|
void onReceiveData(enet::HttpServer* _interface, std::vector<uint8_t>& _data) {
|
||||||
@ -82,7 +82,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
connection.start();
|
connection.start();
|
||||||
|
|
||||||
while (connection.isAlive() == true) {
|
while (connection.isAlive() == true) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <enet/TcpServer.hpp>
|
#include <enet/TcpServer.hpp>
|
||||||
#include <etk/etk.hpp>
|
#include <etk/etk.hpp>
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <etk/stdTools.hpp>
|
#include <etk/stdTools.hpp>
|
||||||
namespace appl {
|
namespace appl {
|
||||||
void onReceiveData(enet::WebSocket* _interface, std::vector<uint8_t>& _data, bool _isString) {
|
void onReceiveData(enet::WebSocket* _interface, std::vector<uint8_t>& _data, bool _isString) {
|
||||||
@ -85,7 +85,7 @@ int main(int _argc, const char *_argv[]) {
|
|||||||
connection.start();
|
connection.start();
|
||||||
|
|
||||||
while (connection.isAlive() == true) {
|
while (connection.isAlive() == true) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user