25#include <condition_variable>
36static const wxString
HOSTNAME( wxT(
"localhost" ) );
55 wxSocketClient* client =
new wxSocketClient;
61 client->Connect( addr,
false );
72 std::lock_guard<std::mutex> lock(
m_mutex );
95 bool Send(
int aService,
const std::string& aMessage )
100 std::lock_guard<std::mutex> lock(
m_mutex );
102 m_message = std::make_pair( aService, aMessage );
118 std::unique_lock<std::mutex> lock(
m_mutex );
132 wxSocketClient* sock_client;
137 addr.Service( port );
189 sock_client =
new wxSocketClient( wxSOCKET_BLOCK );
190 sock_client->SetTimeout( 1 );
191 sock_client->Connect( addr,
false );
192 sock_client->WaitOnConnect( 0, 250 );
194 if( sock_client->Ok() && sock_client->IsConnected() )
196 sock_client->SetFlags( wxSOCKET_NOWAIT );
197 sock_client->Write( message.c_str(), message.length() );
200 sock_client->Close();
201 sock_client->Destroy();
Spin up a thread to send messages via a socket.
void worker()
Actual task that sends data to the socket server.
std::condition_variable m_cv
std::pair< int, std::string > m_message
bool Send(int aService, const std::string &aMessage)
Attempt to send a message if the thread is available.
std::unique_ptr< ASYNC_SOCKET_HOLDER > socketHolder
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
void SocketCleanup()
Must be called to clean up the socket thread used by SendCommand.
static const wxString HOSTNAME(wxT("localhost"))
#define KICAD_PCB_PORT_SERVICE_NUMBER
Pcbnew listens on this port for commands from Eeschema.