1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next

This commit is contained in:
Carles Fernandez 2018-10-21 21:19:23 +02:00
commit dc374ed6ef
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 69 additions and 58 deletions

View File

@ -103,14 +103,16 @@ void TcpCmdInterface::run_cmd_server(int tcp_port)
// Socket and acceptor // Socket and acceptor
boost::asio::io_service service; boost::asio::io_service service;
try
{
boost::asio::ip::tcp::acceptor acceptor(service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)); boost::asio::ip::tcp::acceptor acceptor(service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port));
bool keep_running = true; bool keep_running = true;
while (keep_running) while (keep_running)
{ {
try try
{ {
std::cout << "Telecommand TCP interface listening on port " << tcp_port << std::endl; std::cout << "Telecommand TCP interface listening on port " << tcp_port << std::endl;
boost::asio::ip::tcp::socket socket(service); boost::asio::ip::tcp::socket socket(service);
acceptor.accept(socket, not_throw); acceptor.accept(socket, not_throw);
if (not_throw) if (not_throw)
@ -159,7 +161,7 @@ void TcpCmdInterface::run_cmd_server(int tcp_port)
break; break;
} }
} }
while (error > 0); // && error != boost::asio::error::eof); while (!error); // && error != boost::asio::error::eof);
if (error == boost::asio::error::eof) if (error == boost::asio::error::eof)
{ {
@ -173,11 +175,20 @@ void TcpCmdInterface::run_cmd_server(int tcp_port)
// Close socket // Close socket
socket.close(); socket.close();
} }
catch (const boost::exception &e)
{
std::cout << "Boost exception " << std::endl;
}
catch (const std::exception &ex) catch (const std::exception &ex)
{ {
std::cout << "Exception " << ex.what() << std::endl; std::cout << "Exception " << ex.what() << std::endl;
} }
} }
}
catch (const boost::exception &e)
{
std::cout << "TCP Command Interface exception: address already in use" << std::endl;
}
} }

View File

@ -28,8 +28,8 @@
* *
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#ifndef TCPCMDINTERFACE_H_ #ifndef GNSS_SDR_TCPCMDINTERFACE_H_
#define TCPCMDINTERFACE_H_ #define GNSS_SDR_TCPCMDINTERFACE_H_
#include <functional> #include <functional>
#include <iostream> #include <iostream>
@ -38,7 +38,7 @@
#include <unordered_map> #include <unordered_map>
#include <algorithm> #include <algorithm>
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <stdint.h> #include <cstdint>
class TcpCmdInterface class TcpCmdInterface
@ -61,4 +61,4 @@ private:
void register_functions(); void register_functions();
}; };
#endif /* TCPCMDINTERFACE_H_ */ #endif /* GNSS_SDR_TCPCMDINTERFACE_H_ */