Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How does switching between the threads going at client.c #2

Open
DebuggerShubham opened this issue Feb 3, 2020 · 3 comments

Comments

@DebuggerShubham
Copy link

How does client is able to know when it has to read and when it has to input message

@lovenery
Copy link
Owner

lovenery commented Feb 3, 2020

Due to the mechanism of thread, program can do things simultaneously.
So the client.c can do receiving (trigger when recv) and sending (trigger when user press enter) in the same time.

@DebuggerShubham
Copy link
Author

Is it like that threads automatically context switch between themselves and what if both the threads are sending data to server and there is also 1 thread which is only receiving data

@lovenery
Copy link
Owner

lovenery commented Feb 5, 2020

I remember that for every client, the sever create a thread for it.
So if two clients are sending data to the server, the server has two correspond threads to receive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants