I’m newbie.
I want to make the client program to receive input from keyboard and data from server. I don’t want if while user type something (scanf) and its block to receive data from server.
How to write the code in C ?
Thank you.
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.
Welcome 🙂
I suggest grabbing a copy of Advanced Programming in the Unix Environment, 2nd Edition as soon as you can. It has excellent examples on using
select()(and everything else, too).The source code package on the page above includes an excellent example,
calld/loop.cthat shows more or less exactly what you want — a server loop that accepts connections, adds the connections to the select mask of file descriptors, and handles file descriptors in turn.If you’d like a friendlier interface, investigate libevent. Libevent can give you higher performance on a wide range of platforms and a nice interface. Great for production code, maybe less great for learning how the kernel works.