Im trying to make a console chat program, but have a problem with my loop. I cant get input and receive the other persons input at the same time. If two message or more are sent
The problem is that your recv() call blocks until some data is received, and while recv() is blocking, your program isn't checking to see if there is any input from stdin. The traditional single-threaded solution to this is to set the socket to non-blocking I/O (via EncCon.setblocking(False)) and then have your program block inside select() instead. Pass both EncCon and stdin to select() (as part of its read-socket-set argument) so that select() will return whenever either of them has some data to give to you. (Note that this method doesn't work under Windows, as windows doesn't allow select() to block on stdin :P )