0

How can a client both react to user input and data received from the server?

I created a UDP server, which can handle multiple clients and can react to the data received from each clients. So far the clients only react to user input.

Is it possible, that the clients check for both user input and data on a specific port simultaneously?

1
  • 1
    Just include the stdin file descriptor in your select or poll system call. Commented Oct 12, 2012 at 3:49

2 Answers 2

1

There are multiple way to implement this using multiple process, multi-thread etc. But the most suitable to your application is one process that "multi-plexes" all requests, servicing each request as much as it can. And its solution is select(), poll(), epoll() available in all programming language . Read here and here.

Sign up to request clarification or add additional context in comments.

Comments

0

Consider using threads. Python threading is restricted; only one thread runs at a time within the interpreter, but if a thread is waiting for I/O (or a 'sleep') then other threads can run. You still need to use queues and semaphores and so forth. See the 'threading' module in the library.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.