Commit fa26ffa6 authored by Pedro Oliveira's avatar Pedro Oliveira

fix pip install failure && client.py and server.py dont throw exception after Ctrl^C

parent a11b869c
......@@ -7,4 +7,4 @@ ip route add 0.0.0.0/0 via 10.1.0.2
# install python
apt-get update && apt-get --assume-yes install python3 python3-pip
pip-3.2 install netifaces
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
......@@ -2,7 +2,16 @@ import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -25,6 +34,10 @@ def chooseInterface():
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
......@@ -50,7 +63,7 @@ sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
# Receive/respond loop
while True:
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
......
......@@ -3,6 +3,16 @@ import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -23,8 +33,9 @@ def chooseInterface():
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
#message = 'very important data'
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
......@@ -42,11 +53,10 @@ ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while True:
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
......
......@@ -7,4 +7,4 @@ ip route add 0.0.0.0/0 via 10.0.2.3
# install python
apt-get update && apt-get --assume-yes install python3 python3-pip
pip-3.2 install netifaces
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
......@@ -2,7 +2,16 @@ import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -25,6 +34,10 @@ def chooseInterface():
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
......@@ -50,7 +63,7 @@ sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
# Receive/respond loop
while True:
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
......
......@@ -3,6 +3,16 @@ import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -23,8 +33,9 @@ def chooseInterface():
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
#message = 'very important data'
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
......@@ -42,11 +53,10 @@ ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while True:
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
......
......@@ -7,4 +7,4 @@ ip route add 0.0.0.0/0 via 10.0.3.4
# install python
apt-get update && apt-get --assume-yes install python3 python3-pip
pip-3.2 install netifaces
pip-3.2 install --index-url=https://pypi.python.org/simple/ netifaces
......@@ -2,7 +2,16 @@ import socket
import struct
import sys
import netifaces
import signal
import sys
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -25,6 +34,10 @@ def chooseInterface():
if not hasattr(socket, 'SO_BINDTODEVICE'):
socket.SO_BINDTODEVICE = 25
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
multicast_group = '224.12.12.12'
server_address = ('', 10000)
......@@ -50,7 +63,7 @@ sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP,
# Receive/respond loop
while True:
while is_running:
#print >>sys.stderr, '\nwaiting to receive message'
data, address = sock.recvfrom(10240)
print(data.decode("utf-8"))
......
......@@ -3,6 +3,16 @@ import struct
import sys
import netifaces
import traceback
import signal
is_running = True
sock = None
def exit(signal, frame):
is_running = False
sock.close()
sys.exit(0)
def chooseInterface():
interfaces = netifaces.interfaces()
......@@ -23,8 +33,9 @@ def chooseInterface():
return inputValue
signal.signal(signal.SIGINT, exit)
signal.signal(signal.SIGTERM, exit)
#message = 'very important data'
multicast_group = ('224.12.12.12', 10000)
# Create the datagram socket
......@@ -42,11 +53,10 @@ ip_interface = netifaces.ifaddresses(interface_name)[netifaces.AF_INET][0]['addr
sock.bind((ip_interface, 10000))
try:
# Look for responses from all recipients
while True:
while is_running:
input_msg = input('msg --> ')
try:
sock.sendto(input_msg.encode("utf-8"), multicast_group)
except:
traceback.print_exc()
continue
......
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install -r requirements.txt
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Run.py -stop
python3 Run.py -start
......
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install -r requirements.txt
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Run.py -stop
python3 Run.py -start
......
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install -r requirements.txt
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Run.py -stop
python3 Run.py -start
......
rm -rf MulticastRouting/
cp -rf /hosthome/Desktop/pim/ MulticastRouting/
cd MulticastRouting
pip-3.2 install -r requirements.txt
pip-3.2 install --index-url=https://pypi.python.org/simple/ -r requirements.txt
python3 Run.py -stop
python3 Run.py -start
......
Markdown is supported
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