title: Connecting a Java Server with a Python Client
body: <p>So here's the thing, I have a basic java server that sends back to the client what ever it receives from it. The client is written in python. I'm able to make the first connection as in the server sends the client a message confirming the connection. But when I want the client to send the server something is does nothing. I'm not sure if the problem with the client not sending or the server not receiving.</p>
  
  <p>Here's the code for the server: </p>
  
  <pre><code>    int portNumber = Integer.parseInt(args[0]);
  
      try ( 
          ServerSocket serverSocket = new ServerSocket(portNumber);
          Socket clientSocket = serverSocket.accept();
          PrintWriter outs =
              new PrintWriter(clientSocket.getOutputStream(), true);
          BufferedReader in = new BufferedReader(
              new InputStreamReader(clientSocket.getInputStream()));
      ) {
  
          String inputLine, outputLine;
  
  
          outputLine = "Hello socket, I'm server";
          outs.println(outputLine);
          outs.println("I' connected");
          while ((inputLine = in.readLine()) != null) {
               outputLine = inputLine;
              outs.println(outputLine);
              if (outputLine.equals("Bye."))
                  break;
  
          }
  
      } catch (IOException e) {
          System.out.println("Exception caught when trying to listen on port "
              + portNumber + " or listening for a connection");
          System.out.println(e.getMessage());
      }
  }  }
  </code></pre>
  
  <p>and here's the client :</p>
  
  <pre><code>import socket
  
  HOST = "localhost"
  PORT = 8080
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect((HOST, PORT))
  print (socket.getaddrinfo(HOST,PORT))
  buffer_size = 100
  
  while True :  
      data = sock.recv(buffer_size)     
      print ('you recieved :' , data)
      test = input('send here\n')     
      sock.sendall(bytes(test, 'utf-8'))
      print ('you sent : ' , test)
  </code></pre>