I am creating an executable which should just listen to multiple ports and print (dump) the data. Is it possible to do it in c++? I am only getting examples for server client model.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could create a thread per socket/port and have it do the obvious thing. You could use select to listen to the set of file descriptors and when one becomes ready do the obvious thing.
boost asio may do the heavy lifting for you. http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/tutorial.html