Changeset 110:9ac6386fe9ff in xplra for src/client/c/hu/varadiistvan/xplra/XPlane.cc
- Timestamp:
- 12/23/22 09:09:50 (17 months ago)
- Branch:
- default
- hg-Phase:
- (<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/client/c/hu/varadiistvan/xplra/XPlane.cc
r107 r110 35 35 36 36 #include <hu/varadiistvan/scpl/io/LocalClientSocket.h> 37 #include <hu/varadiistvan/scpl/io/TCPClientSocket.h> 37 38 #include <hu/varadiistvan/scpl/io/DataStream.h> 38 39 … … 52 53 53 54 using hu::varadiistvan::scpl::io::LocalClientSocket; 54 using hu::varadiistvan::scpl::io:: LocalConnector;55 using hu::varadiistvan::scpl::io::TCPClientSocket; 55 56 using hu::varadiistvan::scpl::io::DataStream; 56 57 … … 60 61 using std::string; 61 62 using std::min; 63 64 //------------------------------------------------------------------------------ 65 66 const unsigned short XPlane::defaultTCPPort; 67 68 //------------------------------------------------------------------------------ 69 70 template <class ClientSocket> 71 void XPlane::connect(std::unique_ptr<ClientSocket> clientSocket) 72 { 73 auto& connector = clientSocket->getConnector(); 74 75 while (!connector.connect()) { 76 if (connector.failed()) { 77 throw IOException(connector.getErrorCode()); 78 } 79 waiter.wait(); 80 if (waiter.failed()) { 81 throw IOException(waiter.getErrorCode()); 82 } 83 } 84 85 #ifndef _WIN32 86 signal(SIGPIPE, SIG_IGN); 87 #endif 88 89 socket = clientSocket.release(); 90 stream = new DataStream(*socket); 91 92 for(multiBuffers_t::iterator i = multiBuffers.begin(); 93 i!=multiBuffers.end(); ++i) 94 { 95 MultiBuffer* buffer = *i; 96 buffer->reregisterInXPlane(); 97 } 98 } 62 99 63 100 //------------------------------------------------------------------------------ … … 150 187 unique_ptr<LocalClientSocket> clientSocket(new LocalClientSocket("xplra", 151 188 &waiter)); 152 LocalConnector& connector = clientSocket->getConnector(); 153 154 while (!connector.connect()) { 155 if (connector.failed()) { 156 throw IOException(connector.getErrorCode()); 157 } 158 waiter.wait(); 159 if (waiter.failed()) { 160 throw IOException(waiter.getErrorCode()); 161 } 162 } 163 164 #ifndef _WIN32 165 signal(SIGPIPE, SIG_IGN); 166 #endif 167 168 socket = clientSocket.release(); 169 stream = new DataStream(*socket); 170 171 for(multiBuffers_t::iterator i = multiBuffers.begin(); 172 i!=multiBuffers.end(); ++i) 173 { 174 MultiBuffer* buffer = *i; 175 buffer->reregisterInXPlane(); 176 } 189 connect(std::move(clientSocket)); 190 } 191 192 //------------------------------------------------------------------------------ 193 194 void XPlane::connectTCP(const std::string& address, unsigned short port) 195 { 196 if (socket!=0) return; 197 198 unique_ptr<TCPClientSocket> clientSocket(new TCPClientSocket(address.c_str(), 199 port, 200 &waiter)); 201 connect(std::move(clientSocket)); 177 202 } 178 203
Note:
See TracChangeset
for help on using the changeset viewer.