[DEV] windows port functionnal and update Linux to support select on linux insated of poll
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
@@ -22,6 +23,7 @@ namespace appl {
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -35,7 +37,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test HTTP client ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
// connect on TCP server:
|
||||
enet::Tcp tcpConnection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
// TODO : Check if connection is valid ...
|
||||
@@ -47,16 +48,12 @@ int main(int _argc, const char *_argv[]) {
|
||||
|
||||
// start http connection (the actual state is just TCP start ...)
|
||||
connection.start();
|
||||
enet::HttpRequest req(enet::HTTPReqType::GET);
|
||||
enet::HttpRequest req(enet::HTTPReqType::HTTP_GET);
|
||||
req.setUri("plop.txt");
|
||||
connection.setHeader(req);
|
||||
|
||||
while (connection.isAlive() == true) {
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
@@ -29,6 +30,7 @@ namespace appl {
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -42,7 +44,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test WebSocket client ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
// connect on TCP server:
|
||||
enet::Tcp tcpConnection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
// TODO : Check if connection is valid ...
|
||||
@@ -68,9 +69,5 @@ int main(int _argc, const char *_argv[]) {
|
||||
usleep(100000);
|
||||
timeout--;
|
||||
}
|
||||
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -5,15 +5,17 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/TcpClient.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <etk/stdTools.hpp>
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -27,7 +29,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test TCP client ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
// client mode ...
|
||||
// connect on TCP server:
|
||||
enet::Tcp connection = std::move(enet::connectTcpClient("127.0.0.1", 12345));
|
||||
@@ -37,12 +38,18 @@ int main(int _argc, const char *_argv[]) {
|
||||
return -1;
|
||||
}
|
||||
int32_t iii = 0;
|
||||
int32_t delay = 200;
|
||||
while ( connection.getConnectionStatus() == enet::Tcp::status::link
|
||||
&& iii<10000) {
|
||||
char data[1024];
|
||||
int32_t len = connection.read(data, 1024);
|
||||
TEST_INFO("read len=" << len << " data='" << data << "'");
|
||||
//if (data[len-1] == '2') {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
|
||||
delay--;
|
||||
if (delay == 0) {
|
||||
delay = 500;
|
||||
}
|
||||
int32_t lenWrite = connection.write("get pair value");
|
||||
TEST_INFO("write len=" << lenWrite);
|
||||
//}
|
||||
@@ -59,8 +66,5 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_ERROR("can not unlink to the socket...");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/TcpServer.hpp>
|
||||
@@ -39,6 +40,7 @@ namespace appl {
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -52,7 +54,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test HTTP server ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
//Wait on TCP connection:
|
||||
enet::TcpServer interface;
|
||||
// Configure server interface:
|
||||
@@ -112,8 +113,5 @@ int main(int _argc, const char *_argv[]) {
|
||||
}
|
||||
TEST_INFO("data : " << connection.dataString());
|
||||
*/
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <enet/WebSocket.hpp>
|
||||
@@ -42,6 +43,7 @@ namespace appl {
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -55,7 +57,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test WebSocket server ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
//Wait on TCP connection:
|
||||
enet::TcpServer interface;
|
||||
// Configure server interface:
|
||||
@@ -86,8 +87,5 @@ int main(int _argc, const char *_argv[]) {
|
||||
while (connection.isAlive() == true) {
|
||||
usleep(100000);
|
||||
}
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <enet/enet.hpp>
|
||||
#include <enet/Tcp.hpp>
|
||||
#include <enet/Http.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
@@ -14,6 +15,7 @@
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
enet::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
@@ -27,12 +29,11 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_INFO("==================================");
|
||||
TEST_INFO("== Test TCP server ==");
|
||||
TEST_INFO("==================================");
|
||||
#ifndef __TARGET_OS__Windows
|
||||
//Wait on TCP connection:
|
||||
enet::TcpServer interface;
|
||||
// Configure server interface:
|
||||
interface.setHostNane("127.0.0.1");
|
||||
interface.setPort(31235);
|
||||
interface.setPort(12345);
|
||||
// Start listening ...
|
||||
interface.link();
|
||||
// Wait a new connection ..
|
||||
@@ -62,8 +63,5 @@ int main(int _argc, const char *_argv[]) {
|
||||
TEST_ERROR("can not unlink to the socket...");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
TEST_CRITICAL("not implemented");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user