title: Socket Java client - Python Server
body: <p>I'm tring to implement a java - python client/server socket. The client is in java and the server is write in python</p>
  
  <p><strong>Java Client</strong></p>
  
  <pre><code>import java.io.*;  
  import java.net.*; 
  import java.lang.*;
  
  public class client {
  
  public static void main(String[] args) {  
  
  
  
      try{      
          Socket socket=new Socket("localhost",2004);  
  
          DataOutputStream dout=new DataOutputStream(socket.getOutputStream());  
          DataInputStream din=new DataInputStream(socket.getInputStream());
  
  
          dout.writeUTF("Hello");
          dout.flush();
  
          System.out.println("send first mess");
          String str = din.readUTF();//in.readLine();
  
          System.out.println("Message"+str);
  
  
          dout.close();  
          din.close();
          socket.close();
          }
  
      catch(Exception e){
          e.printStackTrace();}   
  
  
  }  
  
  }
  </code></pre>
  
  <p><strong>Python server</strong></p>
  
  <pre><code>import socket               
  
  soc = socket.socket()         
  host = "localhost" 
  port = 2004                
  soc.bind((host, port))      
  soc.listen(5)                 
  
  while True:
      conn, addr = soc.accept()     
      print ("Got connection from",addr)
      msg = conn.recv(1024)
      print (msg)
      print(len(msg))
  
      if "Hello"in msg:
           conn.send("bye".encode('UTF-8'))
      else:
           print("no message")
  </code></pre>
  
  <p>The first message from client to server was delivery correctly but the second from server to client no. Using telnet I check that sever send the message but the client goes in deadlock and don't receive message.
  I don't understand why.</p>
  
  <p>Thanks</p>