Changeset 111:9c29a0b10ea6 in xplra


Ignore:
Timestamp:
12/23/22 09:10:16 (16 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
Message:

The C client API can connect over TCP

Location:
src/client/c/hu/varadiistvan/xplra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/client/c/hu/varadiistvan/xplra/xplra.cc

    r107 r111  
    498498//------------------------------------------------------------------------------
    499499
     500extern "C" int xplra_connect_tcp(const char* address)
     501{
     502    try {
     503        unique_ptr<Connection> connection(new Connection());
     504        connection->connectTCP(address);
     505        return ConnectionSlot::addValue(connection.release());
     506    } catch(...) {
     507        return -1;
     508    }
     509}
     510
     511//------------------------------------------------------------------------------
     512
     513extern "C" int xplra_connect_tcp_port(const char* address, unsigned short port)
     514{
     515    try {
     516        unique_ptr<Connection> connection(new Connection());
     517        connection->connectTCP(address, port);
     518        return ConnectionSlot::addValue(connection.release());
     519    } catch(...) {
     520        return -1;
     521    }
     522}
     523
     524//------------------------------------------------------------------------------
     525
    500526extern "C" int xplra_get_versions(int connectionID,
    501527                                  int* xplaneVersion, int* xplmVersion,
  • src/client/c/hu/varadiistvan/xplra/xplra.h

    r87 r111  
    142142
    143143/**
    144  * Connect to the simulator.
     144 * Connect to the simulator locally.
    145145 *
    146146 * @return an ID for the created connection, or -1 on error.
    147147 */
    148148int xplra_connect();
     149
     150/*----------------------------------------------------------------------------*/
     151
     152/**
     153 * Connect to the simulator via TCP using the default port.
     154 *
     155 * @return an ID for the created connection, or -1 on error.
     156 */
     157int xplra_connect_tcp(const char* address);
     158
     159/*----------------------------------------------------------------------------*/
     160
     161/**
     162 * Connect to the simulator via TCP using the given port.
     163 *
     164 * @return an ID for the created connection, or -1 on error.
     165 */
     166int xplra_connect_tcp_port(const char* address, unsigned short port);
    149167
    150168/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.