+ 1

Python Threading? or something better?

hey, im trying to make a server-client program that might need to receive data while having the option to type and send data. Threads are making alot of bugs and problems. i found out something like this: while 1: socket_list = [sys.stdin, s] # Get the list sockets which are readable ready_to_read,ready_to_write,in_error = select.select(socket_list , [], []) for sock in ready_to_read: if sock == s: # incoming message from remote server, s data = sock.recv(4096) if not data : print '\nDisconnected from chat server' sys.exit() else : #print data sys.stdout.write(data) sys.stdout.write('[Me] '); sys.stdout.flush() else : # user entered a message msg = sys.stdin.readline() s.send(msg) sys.stdout.write('[Me] '); sys.stdout.flush() now, i dont understand what are all the sys.stdin and all the rest of these sys.std lines.. can anyone explain how it works? btw, this is the client-side... the server-side is fine...

7th Apr 2021, 1:08 PM
Yahel
Yahel - avatar
4 odpowiedzi
+ 1
Coder Kitten wow, thanks! Have a good day
7th Apr 2021, 4:18 PM
Yahel
Yahel - avatar
0
if its an assessment or homework, its ok to try to code socket from the scratch, else django offers you alll what you need in few lines.
8th Apr 2021, 12:04 PM
iTech
iTech - avatar
0
iTech but Django is for web dev... right? How can it help in this situation?
8th Apr 2021, 12:31 PM
Yahel
Yahel - avatar
0
django or flask or whatever web framework will handle client side and server side behind the scene and in few lines, but for your current case help your self with https://www.geeksforgeeks.org/socket-programming-JUMP_LINK__&&__python__&&__JUMP_LINK/
8th Apr 2021, 4:31 PM
iTech
iTech - avatar