Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Sending Files Through Sockets

I am new to socket programming and am trying to send a file from a client to server. I can successfully do this, but I have my code set up to where it should grab and save x files based on how many gets sent. Instead, however, it just reads all the files I send and takes all its contents and puts it into one file. For example, on the client side if I had 2 files named one.txt and two.txt and each had the following contents one, two consecutivley I would want to send that to a server and the server save it on its side as two separate files with the same contents. Instead, what is happening is a file is being made and inside it will have one and two on a newline. 

-------------------------

Here is the server: SERVER
Here is the client: CLIENT[url=https://pastebin.com/F1n1TNLM][/url]

TLDR: I am using Python 3.6 and running this in a Linux environment (Mint). I am just trying to make the 2 files I send save as 2 separate files instead of one
After a couple of changes to the server and one to the client these pieces of code should work

Server.py
Client.py

You just had to move the connection process into the sendFile function, remove a while loop from the server which would stop the client from being able to reconnect and move the 'i' variable outside the while loop in the server to stop the filename always being set to '1'.

Hopefully this helps you


Hope everyone has a wonderful day!
(Dec 1, 2017 05:36 PM)Hello Buddy Wrote:  After a couple of changes to the server and one to the client these pieces of code should work

Server.py
Client.py

You just had to move the connection process into the sendFile function, remove a while loop from the server which would stop the client from being able to reconnect and move the 'i' variable outside the while loop in the server to stop the filename always being set to '1'.

Hopefully this helps you

Thanks so much for your help. This one little problem was killing me. It should be tons easier for me to finish now moving forward. Thanks so much again.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by DoomslayerMar 16, 2021 08:19 AM 9 340 Mar 16, 2021 08:19 AM
Last Post: synchronizing
[C#] by indetectableSep 20, 2020 05:12 AM 13 447 Sep 20, 2020 05:12 AM
Last Post: riu41776
[Python] by xPrimodyJul 27, 2020 01:55 PM 3 164 Jul 27, 2020 01:55 PM
Last Post: Pernat1y