26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG. Using message passing<br />

Architecture & structure<br />

We’ve been talking about “clients” and “servers.” I’ve also used three key phrases:<br />

• “The client sends to the server.”<br />

• “The server receives from the client.”<br />

• “The server replies to the client.”<br />

I specifically used those phrases because they closely reflect the actual function names<br />

used in <strong>Neutrino</strong> message-passing operations.<br />

Here’s the complete list of functions dealing <strong>with</strong> message passing available under<br />

<strong>Neutrino</strong> (in alphabetical order):<br />

• ChannelCreate(), ChannelDestroy()<br />

• ConnectAttach(), ConnectDetach()<br />

• MsgDeliverEvent()<br />

• MsgError()<br />

• MsgRead(), MsgReadv()<br />

• MsgReceive(), MsgReceivePulse(), MsgReceivev()<br />

• MsgReply(), MsgReplyv()<br />

• MsgSend(), MsgSendnc(), MsgSendsv(), MsgSendsvnc(), MsgSendv(),<br />

MsgSendvnc(), MsgSendvs(), MsgSendvsnc()<br />

• MsgWrite(), MsgWritev()<br />

Don’t let this list overwhelm you! You can write perfectly useful client/server<br />

applications using just a small subset of the calls from the list — as you get used to the<br />

ideas, you’ll see that some of the other functions can be very useful in certain cases.<br />

A useful minimal set of functions is ChannelCreate(), ConnectAttach(), MsgReply(),<br />

MsgSend(), and MsgReceive().<br />

We’ll break our discussion up into the functions that apply on the client side, and those<br />

that apply on the server side.<br />

The client<br />

The client wants to send a request to a server, block until the server has completed the<br />

request, and then when the request is completed and the client is unblocked, to get at<br />

the “answer.”<br />

This implies two things: the client needs to be able to establish a connection to the<br />

server and then to transfer data via messages — a message from the client to the server<br />

(the “send” message) and a message back from the server to the client (the “reply”<br />

message, the server’s reply).<br />

April 30, 2009 Chapter 2 • Message Passing 91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!