From 7ec2d1c53b753238509bf7a89587509305b9216d Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Sun, 19 Oct 2008 20:06:14 +0000 Subject: move to asio socket libary for sync bugs / todos: * new connections don't sync * anyrtpproxy broken * anytun-controlld doesn't send data --- src/anytun.cpp | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'src/anytun.cpp') diff --git a/src/anytun.cpp b/src/anytun.cpp index cb4fb48..5bd3214 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -68,11 +68,8 @@ #include "syncCommand.h" #ifndef ANYTUN_NOSYNC -#include "syncSocketHandler.h" -#include "syncListenSocket.h" - -#include "syncSocket.h" -#include "syncClientSocket.h" +#include "syncServer.h" +#include "syncClient.h" #endif #include "threadParam.h" @@ -207,33 +204,25 @@ void syncConnector(void* p ) { ThreadParam* param = reinterpret_cast(p); - SocketHandler h; - SyncClientSocket sock(h,param->cl); - // sock.EnableSSL(); - sock.Open( param->connto.host, param->connto.port); - h.Add(&sock); - while (h.GetCount()) - { - h.Select(); - } + SyncClient sc ( param->connto.host, param->connto.port); + sc.run(); } void syncListener(void* p ) { - ThreadParam* param = reinterpret_cast(p); - - SyncSocketHandler h(param->queue); - SyncListenSocket l(h,param->cl); +// ThreadParam* param = reinterpret_cast(p); - if (l.Bind(gOpt.getLocalSyncPort())) - return; + try + { + asio::io_service io_service; + SyncServer server(io_service,asio::ip::tcp::endpoint(asio::ip::tcp::v4(), gOpt.getLocalSyncPort())); + io_service.run(); + } + catch (std::exception& e) + { + std::cerr << e.what() << std::endl; + } - Utility::ResolveLocal(); // resolve local hostname - h.Add(&l); - h.Select(1,0); - while (1) { - h.Select(1,0); - } } #endif @@ -508,7 +497,7 @@ int main(int argc, char* argv[]) else src = new UDPPacketSource(gOpt.getLocalAddr(), gOpt.getLocalPort()); - ConnectionList cl; + ConnectionList & cl (gConnectionList); ConnectToList connect_to = gOpt.getConnectTo(); SyncQueue queue; -- cgit v1.2.3