21#include <condition_variable>
32static const wxString
HOSTNAME( wxT(
"localhost" ) );
51 wxSocketClient* client =
new wxSocketClient;
57 client->Connect( addr,
false );
68 std::lock_guard<std::mutex> lock(
m_mutex );
91 bool Send(
int aService,
const std::string& aMessage )
96 std::lock_guard<std::mutex> lock(
m_mutex );
98 m_message = std::make_pair( aService, aMessage );
114 std::unique_lock<std::mutex> lock(
m_mutex );
128 wxSocketClient* sock_client;
133 addr.Service( port );
185 sock_client =
new wxSocketClient( wxSOCKET_BLOCK );
186 sock_client->SetTimeout( 1 );
187 sock_client->Connect( addr,
false );
188 sock_client->WaitOnConnect( 0, 250 );
190 if( sock_client->Ok() && sock_client->IsConnected() )
192 sock_client->SetFlags( wxSOCKET_NOWAIT );
193 sock_client->Write( message.c_str(), message.length() );
196 sock_client->Close();
197 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.