Esempio n. 1
0
    def wait_and_receive(self):
        data, addr = self.sock.recvfrom(1024)    # receive file name from server
        if not data:
            print('No response received')
            return

        resfile = data.strip().decode('utf-8')
        filename = f'client_recv_{resfile}'
        self.print(f"Response file Name: {filename}")   # print it

        f = open(filename, "wb") # open that file for writing binary

        rdt_receiver.rdt_rcv(f, self.udp_info, self.sock)
        self.print(f'Finished writing received file {filename}')
Esempio n. 2
0
    def listen(self):
        while True:
            self.print('Listening...')
            msg, addr = self.sock.recvfrom(1024) # receive filename from client
            
            if msg:
                fileName = msg.strip().decode('utf-8') # decode name 
                self.print(f"Recieved file name: {fileName}")

            fileName = f'server_recv_{fileName}' # append server_recv to filename
            self.print(f'Writing filename {fileName}')
            f = open(fileName, 'wb') # open for writing binary
            
            rdt_receiver.rdt_rcv(f, addr, self.sock)	# RDT receive
            self.print(f'Finished writing received file {fileName}')
            self.send_img(addr) # respond by sending an image
Esempio n. 3
0
 def listen(self):
     self.print('Listening...')
     while True:
         addr = rdt_receiver.rdt_rcv(SERVER_RECV_FP,
                                     self.sock)  # RDT receive
         # If didn't get anything then continue
         if not addr:
             continue
         self.print('Finished writing received file')
         self.send_img(addr)  # respond by sending an image
 def wait_and_receive(self):
     rdt_receiver.rdt_rcv(CLIENT_RECV_FP, self.sock)
     self.print('Finished writing received file')