Hello all, hope everyone is doing well.

I have been practicing with sockets and I am trying to send a small png
from the client to the server.

the client code is...

import socket

f = open('/Users/Bo/Desktop/logo_ONEConnxt.png', 'rb')
strf = f.read()
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("ip.ip.ip.ip", 8999))
client_socket.sendall(strf)
f.close()
exit()

and the server code is...

import socket

f = open('img.png', 'wb')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 8999
s.bind(('', port))
s.listen(5)

client_socket, address = s.accept()
data = client_socket.recv(4029)
f.write(data)
client_socket.close()

Both the above client and server code runs without error, however the
"img.png" file that is placed on the server shows zero bytes? Will someone
please show me what I am doing wrong?

Thank you,

Bo
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to