KiCad PCB EDA Suite
eda_dde.cpp File Reference
#include <eda_dde.h>
#include <eda_draw_frame.h>
#include <id.h>
#include <wx/wx.h>

Go to the source code of this file.

Macros

#define IPC_BUF_SIZE   4096
 

Functions

static const wxString HOSTNAME (wxT("localhost"))
 
bool SendCommand (int service, const char *cmdline)
 

Variables

static char client_ipc_buffer [IPC_BUF_SIZE]
 

Macro Definition Documentation

◆ IPC_BUF_SIZE

#define IPC_BUF_SIZE   4096

Definition at line 38 of file eda_dde.cpp.

Function Documentation

◆ HOSTNAME()

static const wxString HOSTNAME ( wxT("localhost")  )
static

◆ SendCommand()

bool SendCommand ( int  service,
const char *  cmdline 
)

Definition at line 131 of file eda_dde.cpp.

132 {
133  wxSocketClient* sock_client;
134  bool success = false;
135  wxIPV4address addr;
136 
137  // Create a connexion
138  addr.Hostname( HOSTNAME );
139  addr.Service( service );
140 
141  // Mini-tutorial for Connect() :-)
142  // (JP CHARRAS Note: see wxWidgets: sockets/client.cpp sample)
143  // ---------------------------
144  //
145  // There are two ways to use Connect(): blocking and non-blocking,
146  // depending on the value passed as the 'wait' (2nd) parameter.
147  //
148  // Connect(addr, true) will wait until the connection completes,
149  // returning true on success and false on failure. This call blocks
150  // the GUI (this might be changed in future releases to honor the
151  // wxSOCKET_BLOCK flag).
152  //
153  // Connect(addr, false) will issue a nonblocking connection request
154  // and return immediately. If the return value is true, then the
155  // connection has been already successfully established. If it is
156  // false, you must wait for the request to complete, either with
157  // WaitOnConnect() or by watching wxSOCKET_CONNECTION / LOST
158  // events (please read the documentation).
159  //
160  // WaitOnConnect() itself never blocks the GUI (this might change
161  // in the future to honor the wxSOCKET_BLOCK flag). This call will
162  // return false on timeout, or true if the connection request
163  // completes, which in turn might mean:
164  //
165  // a) That the connection was successfully established
166  // b) That the connection request failed (for example, because
167  // it was refused by the peer.
168  //
169  // Use IsConnected() to distinguish between these two.
170  //
171  // So, in a brief, you should do one of the following things:
172  //
173  // For blocking Connect:
174  //
175  // bool success = client->Connect(addr, true);
176  //
177  // For nonblocking Connect:
178  //
179  // client->Connect(addr, false);
180  //
181  // bool waitmore = true;
182  // while (! client->WaitOnConnect(seconds, millis) && waitmore )
183  // {
184  // // possibly give some feedback to the user,
185  // // update waitmore if needed.
186  // }
187  // bool success = client->IsConnected();
188  //
189  // And that's all :-)
190 
191  sock_client = new wxSocketClient();
192  sock_client->SetTimeout( 2 ); // Time out in Seconds
193  sock_client->Connect( addr, false );
194  sock_client->WaitOnConnect( 0, 100 );
195 
196  if( sock_client->Ok() && sock_client->IsConnected() )
197  {
198  success = true;
199  sock_client->SetFlags( wxSOCKET_NOWAIT /*wxSOCKET_WAITALL*/ );
200  sock_client->Write( cmdline, strlen( cmdline ) );
201  }
202 
203  sock_client->Close();
204  sock_client->Destroy();
205  return success;
206 }
static const wxString HOSTNAME(wxT("localhost"))

References HOSTNAME().

Referenced by SCH_EDIT_FRAME::SendCrossProbeClearHighlight(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), and SCH_EDIT_FRAME::SetCrossProbeConnection().

Variable Documentation

◆ client_ipc_buffer

char client_ipc_buffer[IPC_BUF_SIZE]
static

Definition at line 39 of file eda_dde.cpp.

Referenced by EDA_DRAW_FRAME::OnSockRequest().