Boost logo

Boost Users :

Subject: Re: [Boost-users] ASIO newbie: Passing parameters from a TCP client to a server
From: Stephan Menzel (stephan.menzel_at_[hidden])
Date: 2009-09-21 08:56:51


On Sat, Sep 19, 2009 at 6:21 PM, Ramon F Herrera <ramon_at_[hidden]> wrote:
> I need the client to pass a few arguments to the server, lets say four.
>
> Should I pass them in 4 different lines?

Generally, it is a much more futureproof idea not to that straight forward but:

a) wrap your data in somthing well structured and parseable such as
boost serialization or google protocol buffers or even XML

b) send the resulting wrapped up data using a well defined transport
layer such as HTTP, also suitable for calls

That way, you won't have to worry about this sort of self made
protocol that tends to become a pain in the source more quickly than
you'd think.

> Being synchronous I suppose the client blocks until the server performs a
> read? (that seems to be what I am seeing now).

pretty much. For details read Stevens. Very useful when one starts
with that sort of thing.

> I heard that there are ways to attach the debugger (gdb) to a server process
> when it starts? (that feat seems to be major wizardry).

No big deal. GDB can do that and even Microsoft's Visual Studio debugger.
Read the appropriate docs.

( $> gdb /path/to/your_binary $PID )

> Sample code would be very appreciated.

Look at the example programs in the boost asio docs. Or, if not so
familiar with modern day C++ at the examples in Steven's Book Unix
Network Programming. Both are excellent starting points, depending on
_where_ you start from and where you want to end up.

Cheers,
Stephan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net