-
Notifications
You must be signed in to change notification settings - Fork 6
/
Relay_socket.py
executable file
·36 lines (26 loc) · 1.25 KB
/
Relay_socket.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
import os
import socket
def main():
TCP_IP = "10.7.23.99" #This is the IP of the pandaboard. It is better to get it from the ip.py file than hardcoding it
TCP_PORT = 5555#the normal port of streaming video on the drone
BUFFER_SIZE = 512 # Normally 1024, but we want fast response
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)#listen on the pandaboard IP and 5555 port which is the video streaming port
print "Server Listening on: " + TCP_IP + ":" +str(TCP_PORT)
while 1:
conn, addr = s.accept()#once we accept the connection
print "connection address: " + str(addr)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
drone_ip = '192.168.2.1'
drone_port = 5555
client.connect((drone_ip, drone_port)) #we connect to our drone
while 1:
data = client.recv(BUFFER_SIZE) #recv data from the drone
#print data
conn.send(data) #send these data to the client connected to the panda board
#We, simply, recieve data from the drone on ip 102.168.2.1 and we RELAY it to who ever connected to us on port 5555
return
if __name__ == '__main__':
main()