Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
client-server pictures
#1
I have codes for both client and server.
It runs smoothly and it looks like that the picture is sent to the client
like expected, however, I am not sure how to display it.
I used the command 'display' but is not showing anything.
How do I fix it?

P.S. The picture file I am using in the server can be changed by any other
png file, you can test with a random one chosen anywhere.

#SERVER CODE import socket port = 60000 s = socket.socket() host = socket.gethostname() s.bind((host, port)) s.listen(5) print ('Server listening....') while True: conn, addr = s.accept() # Establish connection with client. print ('Got connection from', addr) data = conn.recv(1024) print('Server received', repr(data)) filename = 'Lee extended.png' picfile = open(filename,'rb') l = picfile.read(1024) while (l): conn.send(l) print('Sent ',repr(l)) l = picfile.read(1024) picfile.close() print('Done sending') conn.send('Thank you for connecting'.encode()) conn.close()
#CLIENT CODE import socket from IPython.display import display, Image s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 60000 # Reserve a port for your service. s.connect((host, port)) s.send('Hello server!'.encode()) with open('received_file.png', 'rb') as picfile: print ('file is open') while True: print('receiving data...') data = s.recv(1024) print('data=%s', data) display(Image(picfile)) if not data: break #picfile.read(data) picfile.close() print('Successfully get the file') s.close() print('connection closed')
Reply
#2
Let me please know if there is any additional info you would like me to add in order to get at least an answer.
Reply
#3
-----
Reply
#4
nobody knows ?
Reply
#5
https://bit.ly/2Wekgkd
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  client A to server B connects but client B to server A doesnt connect gerald 1 1,482 Aug-17-2024, 07:33 AM
Last Post: Gribouillis
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 2,018 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  Find a shift between 2 pictures TazFleck 0 2,850 Jan-18-2023, 09:56 PM
Last Post: TazFleck
Photo put a green boarder and text around multiple pictures jackosullivan 5 3,329 Jul-05-2022, 10:39 AM
Last Post: snippsat
  creating python server and client in a pc kucingkembar 4 3,779 Nov-29-2021, 01:37 PM
Last Post: kucingkembar
  Real-Time output of server script on a client script. throwaway34 2 3,351 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  How to take the tar backup files form remote server to local server sivareddy 0 3,189 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Random pictures from a file aliwien 2 6,450 Apr-23-2021, 06:00 PM
Last Post: snippsat
  Python sockets : Client sending to the server nico31780 0 3,806 May-17-2020, 07:56 PM
Last Post: nico31780
  Help with taking pictures on raspberry pi octavia 1 2,668 Feb-07-2020, 04:54 PM
Last Post: Larz60+

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.