Commit 8d3a50dc authored by thomas alfroy's avatar thomas alfroy
Browse files

first commit

parent 5efac738
*.c
*.h
makefile
\ No newline at end of file
import socket
import select
import sys
# udp_dest = "127.0.0.1"
# udp_port = 5001
# sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# sock.bind(("127.0.0.1", 5000))
# data, addr = sock.recvfrom(1024)
# sock.sendto(data, (udp_dest, udp_port))
# print("Data succesfully transfered")
# sock_rcv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# sock_rcv.bind(("127.0.0.1", 5002))
# data, addr = sock_rcv.recvfrom(1024)
# sock_rcv.sendto(data, (udp_dest, 5003))
# print("Ack successfully tranfered")
sock_sender = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock_recv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dest_sender = "127.0.0.1"
dest_recv = "127.0.0.1"
port_sender = 5000
port_recv = 5003
sock_sender.bind(("127.0.0.1", 5001))
sock_recv.bind(("127.0.0.1", 5002))
input = [ sock_sender, sock_recv , sys.stdin ]
con = True
while con:
i_ready, o_ready, e_ready = select.select(input, [], [])
for s in i_ready:
if s == sock_sender:
data, addr = sock_sender.recvfrom(1024)
sock_sender.sendto(data, (dest_recv, port_recv))
elif s == sock_recv:
data, addr = sock_recv.recvfrom(1024)
sock_recv.sendto(data, (dest_sender, port_sender))
elif s == sys.stdin:
data = sys.stdin.readline()
data = data.strip()
#print("received data")
if data == "quit":
con = False
else:
print("WTF ?!?")
sock_recv.close()
sock_sender.close()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment