Skip to content
Snippets Groups Projects
Commit f26d92bc authored by Faris Hasim Syauqi's avatar Faris Hasim Syauqi
Browse files

Merge branch 'main' of...

Merge branch 'main' of https://gitlab.informatika.org/if3130-computernotwork/tcp-connection-sim into main
parents 0383a61d 6f90c367
Branches
No related merge requests found
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