From 3a776dd970badb0c4343bf3e8f2565553926b817 Mon Sep 17 00:00:00 2001 From: Othmar Gsenger Date: Mon, 10 Dec 2007 13:24:54 +0000 Subject: added synclistensocket --- anytun.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'anytun.cpp') diff --git a/anytun.cpp b/anytun.cpp index d9b8b1e..8aa768c 100644 --- a/anytun.cpp +++ b/anytun.cpp @@ -47,6 +47,11 @@ #include "seqWindow.h" #include "connectionList.h" +#include "Sockets/SocketHandler.h" +#include "syncListenSocket.h" + +#include "syncSocket.h" + #define PAYLOAD_TYPE_TAP 0x6558 #define PAYLOAD_TYPE_TUN 0x0800 @@ -200,12 +205,23 @@ void* sender(void* p) pthread_exit(NULL); } -void* sync_receiver(void* p) +void* syncReceiver(void* p ) { Param* param = reinterpret_cast(p); - while(1) + SOCKETS_NAMESPACE::SocketHandler h; + SyncListenSocket l(h,param->cl); + + if (l.Bind(23)) + { + exit(-1); + } + Utility::ResolveLocal(); // resolve local hostname + h.Add(&l); + h.Select(1,0); + while (1) { + h.Select(1,0); } } @@ -310,13 +326,17 @@ int main(int argc, char* argv[]) pthread_create(&senderThread, NULL, sender, &p); pthread_t receiverThread; pthread_create(&receiverThread, NULL, receiver, &p); + pthread_t syncReceiverThread; + pthread_create(&syncReceiverThread, NULL, syncReceiver, &p); int ret = sig.run(); pthread_cancel(senderThread); pthread_cancel(receiverThread); + pthread_cancel(syncReceiverThread); pthread_join(senderThread, NULL); pthread_join(receiverThread, NULL); + pthread_join(syncReceiverThread, NULL); delete src; -- cgit v1.2.3