Changeset 104:a41f04cda4c2 in xplra


Ignore:
Timestamp:
12/15/22 19:15:24 (2 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The plugin accepts connections over TCP as well

Location:
src/plugin/src/xplra
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/ListenThread.cc

    r61 r104  
    1 // Copyright (c) 2013 by István Váradi
     1// Copyright (c) 2022 by István Váradi
    22
    33// This file is part of XPLRA, a remote-access plugin for X-Plane
     
    3535#include <hu/varadiistvan/scpl/io/LocalServerSocket.h>
    3636#include <hu/varadiistvan/scpl/io/LocalAcceptor.h>
     37#include <hu/varadiistvan/scpl/io/TCPServerSocket.h>
     38#include <hu/varadiistvan/scpl/io/TCPAcceptor.h>
    3739#include <hu/varadiistvan/xplcommon/Util.h>
    3840
     
    4345using hu::varadiistvan::scpl::io::LocalServerSocket;
    4446using hu::varadiistvan::scpl::io::LocalAcceptor;
     47using hu::varadiistvan::scpl::io::TCPServerSocket;
     48using hu::varadiistvan::scpl::io::TCPAcceptor;
    4549using hu::varadiistvan::xplcommon::Util;
    4650
     
    5155    Util::debug("xplra::ListenThread::run: started\n");
    5256
    53     LocalServerSocket socket("xplra", &waiter);
    54     LocalAcceptor& acceptor = socket.getAcceptor();
    55     while(!quitEvent.check() && !quitEvent.failed() && !acceptor.failed()) {
    56         while (acceptor.accept()) {
     57    LocalServerSocket localSocket("xplra", &waiter);
     58    LocalAcceptor& localAcceptor = localSocket.getAcceptor();
     59
     60    TCPServerSocket tcpSocket(defaultTCPPort, &waiter);
     61    TCPAcceptor& tcpAcceptor = tcpSocket.getAcceptor();
     62
     63    while(!quitEvent.check() && !quitEvent.failed() &&
     64          !localAcceptor.failed() && !tcpAcceptor.failed()) {
     65        while (localAcceptor.accept()) {
    5766            ServerThread* serverThread = new ServerThread(*this,
    5867                                                          requestQueue,
    59                                                           acceptor);
     68                                                          localAcceptor);
     69            serverThread->start();
     70        }
     71        while (tcpAcceptor.accept()) {
     72            ServerThread* serverThread = new ServerThread(*this,
     73                                                          requestQueue,
     74                                                          tcpAcceptor);
    6075            serverThread->start();
    6176        }
  • src/plugin/src/xplra/ListenThread.h

    r46 r104  
    5656class ListenThread : public hu::varadiistvan::scpl::Thread
    5757{
     58public:
     59    /**
     60     * The default TCP port number ("XR")
     61     */
     62    static const unsigned short defaultTCPPort = 0x5852;
     63
    5864private:
    5965    /**
  • src/plugin/src/xplra/Makefile.am

    r91 r104  
    7272win_xpl_SOURCES=$(SRCS)
    7373
    74 win_xpl_LDADD=$(LIBXPLCOMMON_LIBS) $(VSCPL_LIBS)
     74win_xpl_LDADD=$(LIBXPLCOMMON_LIBS) $(VSCPL_LIBS) -lws2_32
    7575win_xpl_LDADD+=@XPSDK_LDFLAGS@
    7676if TARGET_API_WIN64
  • src/plugin/src/xplra/ServerThread.cc

    r81 r104  
    5454using xplra::ServerThread;
    5555
    56 using hu::varadiistvan::scpl::io::LocalAcceptor;
     56using hu::varadiistvan::scpl::io::BufferedStreamAcceptor;
    5757using hu::varadiistvan::scpl::Mutex;
    5858using hu::varadiistvan::xplcommon::Util;
     
    9797
    9898ServerThread::ServerThread(ListenThread& listenThread,
    99                            RequestQueue& requestQueue, LocalAcceptor& acceptor) :
     99                           RequestQueue& requestQueue,
     100                           BufferedStreamAcceptor& acceptor) :
    100101    listenThread(listenThread),
    101102    requestQueue(requestQueue),
    102     bufferedStream(acceptor.getSocket(&waiter)),
     103    bufferedStream(acceptor.getAcceptedBufferedStream(&waiter)),
    103104    stream(*bufferedStream),
    104105    nextGetMultiRequestID(1),
  • src/plugin/src/xplra/ServerThread.h

    r81 r104  
    3838#include <hu/varadiistvan/scpl/io/BufferedStream.h>
    3939#include <hu/varadiistvan/scpl/io/DataStream.h>
    40 #include <hu/varadiistvan/scpl/io/LocalAcceptor.h>
     40#include <hu/varadiistvan/scpl/io/BufferedStreamAcceptor.h>
    4141
    4242#include <hu/varadiistvan/scpl/Mutex.h>
     
    154154     */
    155155    ServerThread(ListenThread& listenThread, RequestQueue& requestQueue,
    156                  hu::varadiistvan::scpl::io::LocalAcceptor& acceptor);
     156                 hu::varadiistvan::scpl::io::BufferedStreamAcceptor& acceptor);
    157157
    158158    /**
Note: See TracChangeset for help on using the changeset viewer.