File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed
Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 1010msg = server .recv (1024 )
1111print (msg .decode ('utf-8' ) + "\n " )
1212
13- emptyResponseCommands = ["cls" ]
13+ emptyResponseCommands = ["cls" , "exit" ]
1414
1515while True :
1616 cwd = os .getcwd ().encode ("utf-8" )
2323 print ("\n Connection Terminated." )
2424 break
2525 else :
26- print (command )
27-
2826 if command == "cd .." or command == "cd.." :
2927 curDir = cwd .decode ("utf-8" ).split ("\\ " )
3028 os .chdir ("\\ " .join (curDir [:len (curDir )- 1 ]))
3634 server .send (b"COMMAND EXCPETION." )
3735 elif command == "RESPOND NULL" :
3836 continue
37+ elif "copy()" in command :
38+ fileName = command .split (".copy()" )
39+ fileAlias = open (fileName [0 ], "rb" )
40+ binaryData = fileAlias .read (1024 )
41+ while binaryData :
42+ binaryData = fileAlias .read (1024 )
43+ server .send (binaryData )
44+ server .send (b"EOF" )
3945 elif command in emptyResponseCommands :
4046 server .send (b"This command is currently not supported.\n " )
4147 else :
Original file line number Diff line number Diff line change 1+ random text
Original file line number Diff line number Diff line change 1111-> Responses are delayed. Everything requires an additional Enter. [FIXED]
1212
1313-> Prompt breaks for empty responses. [FIXED]
14+
15+ -> File isn't copied over connection.
Original file line number Diff line number Diff line change 11import socket
22
3- serversocket = socket .socket (
4- socket .AF_INET , socket .SOCK_STREAM )
3+ serversocket = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
54
65host = socket .gethostname ()
76port = 6969
1211
1312clientsocket , addr = serversocket .accept ()
1413clientsocket .send (b"Connection Succesful." )
15- #print(addr)
14+
15+ customCommands = ["download()" , "upload()" ]
1616
1717print ("Connection Succesful.\n " )
1818print ("\n \n =====CLIENT TERMINAL=====\n \n " )
1919
2020while True :
21-
2221 cwd = "NOT A DIRECTORY"
22+
2323 while cwd == "NOT A DIRECTORY" :
2424 cwd = clientsocket .recv (1024 ).decode ("utf-8" )
2525
3131 break
3232 elif command == "" :
3333 clientsocket .send (b"RESPOND NULL" )
34+ elif "copy()" in command :
35+ fileName = command .split (".copy()" )
36+ copyFile = open (fileName [0 ], "ab" )
37+ clientsocket .send (command .encode ("utf-8" ))
38+
39+ while True :
40+ filePart = clientsocket .recv (1024 )
41+ if filePart == b"EOF" :
42+ copyFile .close ()
43+ break
44+ copyFile .write (filePart )
3445 else :
3546 clientsocket .send (command .encode ("utf-8" ))
3647 output = clientsocket .recv (1024 ).decode ("utf-8" )
You can’t perform that action at this time.
0 commit comments