MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / main

Function main

file_transfer/receive_file.py:4–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3
4def main():
5 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
6 host = socket.gethostname()
7 port = 12312
8
9 sock.connect((host, port))
10 sock.send(b"Hello server!")
11
12 with open("Received_file", "wb") as out_file:
13 print("File opened")
14 print("Receiving data...")
15 while True:
16 data = sock.recv(1024)
17 if not data:
18 break
19 out_file.write(data)
20
21 print("Successfully received the file")
22 sock.close()
23 print("Connection closed")
24
25
26if __name__ == "__main__":

Callers 1

receive_file.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected