Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clearer file handler names
  • Loading branch information
AlexDvorak committed Aug 7, 2019
commit 3f8af015c089adec9c7a87dd1aab7aa5fdfebbfa
4 changes: 2 additions & 2 deletions file_transfer_protocol/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sock.connect((host, port))
sock.send(b'Hello server!')

with open('Received_file', 'wb') as file:
with open('Received_file', 'wb') as in_file:
print('File opened')
print('Receiving data...')
while True:
Expand All @@ -16,7 +16,7 @@
if not data:
break
# write data to a file
file.write(data)
in_file.write(data)

print('Successfully got the file')
sock.close()
Expand Down
8 changes: 4 additions & 4 deletions file_transfer_protocol/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
print('Server received', repr(data))

filename='mytext.txt'
file = open(filename,'rb')
data = file.read(1024)
out_file = open(filename,'rb')
data = out_file.read(1024)
while (data):
conn.send(data)
print('Sent ',repr(data))
data = file.read(1024)
file.close()
data = out_file.read(1024)
out_file.close()

print('Done sending')
conn.send(b'Thank you for connecting')
Expand Down