-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrasp_server.py
37 lines (32 loc) · 1.04 KB
/
rasp_server.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
37
import os
import argparse
import socket
from server import Server
### Mandatory parameters
parser = argparse.ArgumentParser(description="Launch a raspberry stream server.")
parser.add_argument('--address', '-ad', required=True,
help='Address of the server')
parser.add_argument('--port', '-p', required=True,
help='Port to listen')
### Optionnal parameters
parser.add_argument('--timeout', '-t', required=False,
help='Timeout of the server')
## Get parameters in variables
args = vars(parser.parse_args())
address = args.pop('address')
port = args.pop('port')
timeout = args.pop('timeout')
### Init of socket
server = Server(address, port, timeout)
server.begin_listen()
# socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# try:
# socket.bind((address, port))
# print('Server bind to {}:{}'.format(address, port))
# except:
# print('Server not able to bind to {}:{}'.format(address, port))
#
# if timeout:
# socket.settimeout(timeout)
# else:
# socket.settimeout(2)