mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
* add final else-statement * fix file_transfer * fix quantum folder * fix divide_and_conquer-folder * Update build.yml * updating DIRECTORY.md * Update ripple_adder_classic.py * Update .github/workflows/build.yml * removed imports from typing * removed conversion to string * Revert "removed conversion to string" This reverts commit 2f7c4731d103f24c73fb98c9a6898525998774c5. * implemented suggested changes * Update receive_file.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
24 lines
656 B
Python
24 lines
656 B
Python
if __name__ == "__main__":
|
|
import socket # Import socket module
|
|
|
|
sock = socket.socket() # Create a socket object
|
|
host = socket.gethostname() # Get local machine name
|
|
port = 12312
|
|
|
|
sock.connect((host, port))
|
|
sock.send(b"Hello server!")
|
|
|
|
with open("Received_file", "wb") as out_file:
|
|
print("File opened")
|
|
print("Receiving data...")
|
|
while True:
|
|
data = sock.recv(1024)
|
|
print(f"{data = }")
|
|
if not data:
|
|
break
|
|
out_file.write(data) # Write data to a file
|
|
|
|
print("Successfully got the file")
|
|
sock.close()
|
|
print("Connection closed")
|