summaryrefslogtreecommitdiff
path: root/anytun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'anytun.cpp')
-rw-r--r--anytun.cpp24
1 files changed, 22 insertions, 2 deletions
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<Param*>(p);
- while(1)
+ SOCKETS_NAMESPACE::SocketHandler h;
+ SyncListenSocket<SyncSocket,ConnectionList> 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;