Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate an iostream using boost asio specifying ip and port
    primarykey
    data
    text
    <p>I have a problem concerning boost asio libraries. I successfully tried to create a socket between a client and a server, this involves creation of resolvers in order to specify ip and port to the server (the server only requires port) and other objects, but, most importantly, it is necessary to use <code>write</code> and <code>read_some</code> as functions to read and write from/in the socket. I would really appreciate to use a stream, and this is possible in boost asio, but that's strange... In almost all examples using streams, to create a server it is necessary to provide port, ok, let's talk about the client... client side, it is necessary to use the iostream constructor to specify coordinates for connecting the stream, here's the code:</p> <pre><code>tcp::iostream() s(argv[1], "daytime"); </code></pre> <p>Well, I don't really understand what is passed in the first parameter and really don't know what daytime might ever represent... Basically, here, I'm telling: "Hey stream, you must connect to this server..." but how can I specify ip and port of that server? Note that, on the opposite, everything is almost clear server side:</p> <pre><code>boost::asio::io_service io_s; tcp::acceptor acc(io_s, tcp::endpoint(tcp::v4(), 1950)); for (;;) { tcp::iostream stream; acc.accept(*stream.rdbuf()); stream &lt;&lt; "Message" &lt;&lt; std::endl; } </code></pre> <p>Using this model, I would like to use</p> <pre><code>stream &lt;&lt; mymessage_to_send &lt;&lt; std::endl; stream &gt;&gt; a_string_containing_my_message; </code></pre> <p>in order to send and receive. How can I do this? Thank you very much.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload