Problem with socket path

Problem with socket path

Postby frenk89 » Fri Jun 27, 2014 3:13 pm

Hello guys i created a python file transfer with socket tcp.....and it work fine,but my "problem" is that i want to send with my client tha path at the server and the server send me a file.....for example:
Code: Select all
client send /home/folder/myfile.txt

server received the path read the file in binary mode and send it, i tried
Code: Select all
#client-----:
sock.sendall("/home/folder/myfile.txt".encode())

#server-----:
file=sockread.decode('utf-8')
sender = open(file, 'rb')
data = file.read(1024)
sock.sendall(data)

and client receive and write the binary data but the problem is that the client stop to 1024 bytes received

instead if i specific the path in the code like:
Code: Select all
sender = open("/home/folder/myfile.txt", 'rb')

the client receives the file perfectly and i have no problem with client,because it does not stop at 1024 bytes but finish it until the end

thanks in advanced
Last edited by Yoriz on Fri Jun 27, 2014 3:24 pm, edited 1 time in total.
Reason: First post lock, Added code tags.
frenk89
 
Posts: 4
Joined: Fri Jun 27, 2014 3:04 pm

Re: Problem with socket path

Postby Yoriz » Fri Jun 27, 2014 3:24 pm

Welcome to the forum.
Please read the new user read this link in my signature.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 838
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Problem with socket path

Postby frenk89 » Fri Jun 27, 2014 3:35 pm

Yoriz wrote:Welcome to the forum.
Please read the new user read this link in my signature.


I read now thank you for the welcome :)
frenk89
 
Posts: 4
Joined: Fri Jun 27, 2014 3:04 pm


Return to Networking

Who is online

Users browsing this forum: No registered users and 1 guest

cron