Python Forum
Client/Server proper finalizing transfer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Client/Server proper finalizing transfer
#2
ahhhhh I figured it out. I took out the "if not data" statement and replaced it with "if c == file_size" and it breaks successfully without breaking the connection.


server:

with open("node.msi", "rb") as file:
                    c = 0
                    start_time = time.time()
                    while c <= file_size:
                        data = file.read(1024)
                        conn.send(data)
                        c = c + len(data)
                        if c == file_size:
                            end_time = time.time()
                            print("send time: ", end_time - start_time)
                            file.close()
                            break
client:

with open("./recv/" + "node.msi", "wb") as file:
                    c = 0
                    start_time = time.time()
                    while c <= int(file_size):
                        data = client_socket.recv(1024)
                        file.write(data)
                        c = c + len(data)
                        if c == int(file_size):
                            file.close()
                            end_time = time.time()
                            print("download time: ", end_time - start_time)
                            break
Reply


Messages In This Thread
RE: Client/Server proper finalizing transfer - by wolfman5874 - Jul-04-2022, 07:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,914 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
Bug Problem connecting TLS client written in C++ and Twisted server gpropf 0 1,439 Jun-12-2022, 05:57 PM
Last Post: gpropf
  Server/client basic communication ebolisa 0 2,082 Sep-30-2021, 12:22 PM
Last Post: ebolisa
  Client server Multithreading Anan 6 6,041 Apr-21-2021, 08:19 PM
Last Post: SheeppOSU
Question Trouble with Client/Server reverse Shell! Gilush 0 2,843 Feb-03-2021, 01:04 PM
Last Post: Gilush
  Basic client server code question swisscheese 4 3,312 Dec-12-2020, 08:51 AM
Last Post: Larz60+
  How can i create a server for already existing client using Python? Chapanson 21 7,842 Aug-19-2020, 09:12 AM
Last Post: DeaD_EyE
  Simple TCP Client and TCP Server Problem Vapulabis 5 4,482 Jul-12-2020, 05:09 PM
Last Post: ndc85430
  how to send an image from server to client using PICKLE module dafdaf 1 3,162 Jun-02-2020, 01:08 PM
Last Post: nuffink
  how can i send a list of tuples from the server to the client using sockets? dafdaf 1 3,992 Apr-13-2020, 10:51 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020