KiCad PCB EDA Suite
eda_dde.cpp File Reference
#include <fctsys.h>
#include <eda_dde.h>
#include <draw_frame.h>
#include <id.h>
#include <common.h>
#include <macros.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

#define IPC_BUF_SIZE   4096

Definition at line 39 of file eda_dde.cpp.

Referenced by EDA_DRAW_FRAME::OnSockRequest().

Function Documentation

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

Definition at line 132 of file eda_dde.cpp.

References HOSTNAME().

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

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

Variable Documentation

char client_ipc_buffer[IPC_BUF_SIZE]
static

Definition at line 40 of file eda_dde.cpp.