Skip to content
Snippets Groups Projects
Commit 6f90c367 authored by Mgs. Tabrani's avatar Mgs. Tabrani
Browse files

Merge branch 'send-file-and-close-connection' into 'main'

Add send file and close connection

See merge request !1
parents 32a23d79 2766eba2
1 merge request!1Add send file and close connection
import socket
import sys
import os
from common import *
class Server():
......@@ -80,11 +81,26 @@ class Server():
def send_file(self, client_addr):
# To-Do
return
file_size = os.path.getSize(self.FILE_PATH)
with open(self.FILE_PATH, "rb") as f:
file = f.read()
log("!", "File is loaded")
segments = Segment()
log("!", f"File segmented into {len(file) // SEG_SIZE} segments")
self.send(self.FILE_PATH + f"-{file_size}", client_addr)
log("!", "File path and size sent")
return True
def close_con(self, client_addr):
# To-Do
return
self.socket.close()
log("!", "Connection is closed")
return True
if __name__=="__main__":
try:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment