Python Client Server program gets stucked -


server code

import socket server_socket = socket.socket(socket.af_inet, socket.sock_stream) server_socket.bind(("192.168.169.10", 9559)) server_socket.listen(5) import os import time  client_socket, address = server_socket.accept() print "conencted - ",address,"\n"  while(1):  fp = open('img.jpg','wb+')  start = time.time() while true:     strng = client_socket.recv(1024)     if not strng:         break         print 'loop ends'     fp.write(strng) fp.close()  print 'total time taken',time.time()-start,'secs' print "data received successfully"  client_socket.send("hey looking face")   exit() 

client code

import socket,os client_socket = socket.socket(socket.af_inet, socket.sock_stream) client_socket.connect(("192.168.169.10", 9559))  fname = '/home/student/images/andrew1.jpeg' img = open(fname,'rb')  while true: strng = img.readline(1024) if not strng:     break client_socket.send(strng) img.close()  response = client_socket.recv(1024) print response exit() 

the code gets stucked , when on client side ctrl +c pressed server exits , client doesnt receive data how achieve 2 way communication in scenario ??


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -