0

Socket

How can you send a message in a server using socket? I want to create a server that can send msgs to client and they can send msgs back. Plssssss help!

15th Aug 2018, 5:20 PM
Hayden
3 Respostas
+ 1
i dunno, i'm not a good python programmer, but i think that's possible using scapy https://scapy.net
16th Aug 2018, 2:10 AM
pedro
pedro - avatar
0
Alright ill check it out! Thx
16th Aug 2018, 3:29 AM
Hayden
0
ummm... what a delay :) use this tamplet (only works for one client at a time): import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(('0.0.0.0', 8820)) server_socket.listen() client_conn, addr = server_socket.accept() while True: data = client_conn.recv(1024).decode() print(f"Client Said {data}") if data == 'Quit': client_conn.send('OK, Bye'.encode()) break else: client_conn.send(data.encode()) client_conn.close() server_socket.close()
23rd Mar 2021, 4:40 PM
Yahel
Yahel - avatar