0

I currently have a server using Asio like the example here. Currently, it works as intended in that every packet it receives from the client is responded to by the session::handle_read function.

However, I want to modify the server so that it can also accept data from the command line and send that across the packet to the client (unsolicited by the client) while still listening for input from the client.

I'm not really sure where to start modifying what I have... so pointers there would be helpful. I'm thinking that I need additional work in the session::start function (e.g. read from the command line then use an async_write to write out that data); does that seem logical?

NmdMystery
  • 2,778
  • 3
  • 32
  • 60
Alex Mullans
  • 1,699
  • 2
  • 17
  • 34

1 Answers1

1

I want to modify the server so that it can also accept data from the command line and send that across the packet to the client

Use a posix::stream_descriptor to read from STDIN_FILENO. See this previous question and answer for a more complete example and solution.

Community
  • 1
  • 1
Sam Miller
  • 23,808
  • 4
  • 67
  • 87