[DEV] remove dependency of unistd.h

This commit is contained in:
Edouard DUPIN 2016-10-13 21:29:18 +02:00
parent 1d63f0188f
commit 6fa2ed2003
7 changed files with 19 additions and 19 deletions

View File

@ -9,7 +9,7 @@
#include <map>
#include <etk/stdTools.hpp>
#include <cstring>
#include <unistd.h>
static std::string escapeChar(const std::string& _value) {
return _value;
@ -147,7 +147,7 @@ void enet::Http::start() {
}
while ( m_threadRunning == true
&& m_connection.getConnectionStatus() != enet::Tcp::status::link) {
usleep(50000);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
//ethread::setPriority(*m_receiveThread, -6);
ENET_DEBUG("connect [STOP]");
@ -364,7 +364,7 @@ void enet::Http::getHeader() {
char type;
int32_t len = m_connection.read(&type, 1);
if (len == 0) {
usleep(1);
std::this_thread::sleep_for(std::chrono::microseconds(1));
continue;
}
header += type;

View File

@ -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);
if (socketId < 0) {
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
usleep(200000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
}
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);
if (iResult != 0) {
ENET_ERROR("getaddrinfo failed with error: " << iResult);
usleep(200000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
}
@ -92,7 +92,7 @@ enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8
if (socketId == INVALID_SOCKET) {
ENET_ERROR("Unable to connect to server!");
usleep(200000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
} else {
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);
if (socketId < 0) {
ENET_ERROR("ERROR while opening socket : errno=" << errno << "," << strerror(errno));
usleep(200000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
}
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());
if (server == nullptr) {
ENET_ERROR("ERROR, no such host : " << _hostname);
usleep(200000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
}
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;
}
ENET_ERROR("ERROR connecting, maybe retry ... errno=" << errno << "," << strerror(errno));
usleep(500000);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
continue;
}
// if we are here ==> then the connextion is done corectly ...

View File

@ -12,7 +12,7 @@
#include <random>
#include <algue/base64.hpp>
#include <algue/sha1.hpp>
#include <unistd.h>
namespace enet {
@ -148,7 +148,7 @@ void enet::WebSocket::start(const std::string& _uri, const std::vector<std::stri
|| m_interface->isAlive() == false) {
break;
}
usleep(10000);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
timeout--;
}
if ( m_connectionValidate == false

View File

@ -12,7 +12,7 @@
#include <etk/etk.hpp>
#include <etk/stdTools.hpp>
#include <unistd.h>
namespace appl {
void onReceiveData(std::vector<uint8_t>& _data) {
@ -53,7 +53,7 @@ int main(int _argc, const char *_argv[]) {
connection.setHeader(req);
while (connection.isAlive() == true) {
usleep(100000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return 0;
}

View File

@ -13,7 +13,7 @@
#include <etk/etk.hpp>
#include <etk/stdTools.hpp>
#include <unistd.h>
namespace appl {
void onReceiveData(std::vector<uint8_t>& _data, bool _isString) {
@ -66,7 +66,7 @@ int main(int _argc, const char *_argv[]) {
int32_t timeout = 20;
while (connection.isAlive() == true
&& timeout > 0) {
usleep(100000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
timeout--;
}
return 0;

View File

@ -11,7 +11,7 @@
#include <enet/TcpServer.hpp>
#include <etk/etk.hpp>
#include <unistd.h>
#include <etk/stdTools.hpp>
namespace appl {
void onReceiveData(enet::HttpServer* _interface, std::vector<uint8_t>& _data) {
@ -82,7 +82,7 @@ int main(int _argc, const char *_argv[]) {
connection.start();
while (connection.isAlive() == true) {
usleep(100000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

View File

@ -12,7 +12,7 @@
#include <enet/TcpServer.hpp>
#include <etk/etk.hpp>
#include <unistd.h>
#include <etk/stdTools.hpp>
namespace appl {
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();
while (connection.isAlive() == true) {
usleep(100000);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return 0;
}