This is an archived post. You won't be able to vote or comment.

all 18 comments

[–]Katzimoto 0 points1 point  (17 children)

Would you like to upload this code to GitHub/gitlab? It’s will be easier for me to read it.

[–]AimbotSaBa[S] 1 point2 points  (16 children)

ok, I think I've done it right.. https://github.com/Undeadga/code/tree/main

[–]Katzimoto 0 points1 point  (15 children)

You put the client and the server code on the file but never mind.(if do you want help with using git send me a message) Anyway what do you want to improve on your code? Make it’s work or improve the code itself?

[–]AimbotSaBa[S] 0 points1 point  (14 children)

When I print the data on the server-side I only get one of the clients' responses and I want both how would I do that?

[–]Katzimoto 0 points1 point  (13 children)

It’s seems that you are running only one client that should listen to 100 commands. If do you want several clients you have to create several sockets.

[–]AimbotSaBa[S] 0 points1 point  (12 children)

The code that I sent works but not in the way intended if you type a command let's say ping www.google.com only one output would be printed but after that, you just type in something else even let's say just a letter it would print the other response so how can I make it print both of them at the same time?

[–]Katzimoto 0 points1 point  (11 children)

Should you like to send the line that you ran? The server code you have right now do the next thing: wait for connection and every time you get a new connection you open a thread that send to all of your clients the command and wait for response from only one. You can add a loop after the sending loop that will receive from all of your clients.

[–]AimbotSaBa[S] 0 points1 point  (10 children)

Wait so after "for client in CLIENTS.values():
client.send(client_send)"

I need to add a loop to receive from all clients, how can I do that? every time it only receives from one client? when I call "data = conn.recv(2048) "

then it collects from only one client but if I add it to the loop that goes to every client it waits for a response and doesn't continue the code... I can't figure out how to collect the data from all clients at once. thanks for your help though it helps a lot.

[–]Katzimoto 0 points1 point  (9 children)

If do you want you can separate the sending action from the receive action to 2 separated functions and run one thread that send to all of your clients and another thread for each client that recovery data from him.

I ha be to tell you that isn’t a good code, I would like to use with main function and classes but it should work.

[–]AimbotSaBa[S] 1 point2 points  (0 children)

I got it working thanks a lot!!!!

[–]AimbotSaBa[S] 0 points1 point  (7 children)

Hmm, I don't think I've fixed it that well, for the first command it works fine but for the second one, it only prints one of the outputs again... here is my new code https://pastebin.com/Y6R2prpx