Skip to content

Commit

Permalink
in class 2 fixed some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdrph committed Oct 8, 2018
1 parent 5d7fca7 commit 4ae5824
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions bs/BS.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def udp_cs(sock):
msg = b''
try:
msg = sock.recv(1024)
print(msg)
except socket.error:
print('ERROR_SOCKET_UDP_RECEIVE')
sock.close()
Expand All @@ -59,7 +60,8 @@ def udp_cs(sock):
'LSF':lsf
}
while True:
message = get_msg(sock)
#message = get_msg(sock)

if not message: break
args = message.split()
callable = actions.get(args[0])
Expand Down Expand Up @@ -98,7 +100,8 @@ def register_with_cs():

# UDP
udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
cs_addr = (cmd_line_args['csname'], cmd_line_args['csport'])
addr = (cmd_line_args['csname'], cmd_line_args['bsport'])
udp_sock.bind( addr )
udp_sock.setblocking(False)
sel.register(udp_sock, selectors.EVENT_READ, udp_cs)

Expand Down
12 changes: 9 additions & 3 deletions cs/CS.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ def lsf(args, user_socket, cred):
with open(path) as f:
ip = f.read().split()
udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = (ip[0], ip[1])
addr = (ip[0], int(ip[1]))
print(addr)
cmd = 'LSF '+cred[0]+' '+args[0]+'\n'
udp_sock.sendto(cmd.encode('utf-8'), addr)
try:
udp_sock.sendto(cmd.encode('utf-8'), addr)
except:
udp_sock.close()
exit()
udp_sock.close()
#falar com bs
#bs retorna filelist
#dar esta filelist ao user
Expand Down Expand Up @@ -226,7 +232,7 @@ def udp_rgr(udp_sock):
server_address = ('localhost', cmd_line_args['csport'])
tcp_sock.bind(server_address)
print('listening...')
tcp_sock.listen()
tcp_sock.listen(1)
tcp_sock.setblocking(False)
sel.register(tcp_sock, selectors.EVENT_READ, tcp_accept)

Expand Down

0 comments on commit 4ae5824

Please sign in to comment.