TCP Socket communication Java – Python

I want to transmit an integer number throught a socket.
I have a python script that open a socket and wait for requests, in the other side there is a Java servlet that send a request at this socket to obtain a value.

All the communication works well the problem is that the value obtained from java cause a EOFexception. I’ve tried some convertion and formats in the python script (I’m not expert of this language) but nothing works.

Instead, if I use in python a echo socket, picking all that socket receive and send back to java, all working fine.

But I need to send a simple value.

The following is the portion of code that I use, I’ve tried with float, this is with a String value:

[Python socket related istructions]

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(server_address)
sock.listen(1)
connection = sock.accept()

[Python echo socket working]

data = connection.recv(16)
if data:
    connection.sendall(data)

instead I want to do:

[Python return a example value]

 connection.sendall('55')

That working if I send request from a client like Hercules but cause a EOFexception in Java

[Java Servlet – send request]

socket = new Socket(address, port);
dataInputStream = new DataInputStream(socket.getInputStream());
String content = dataInputStream.readUTF(); //EOFexception
Destination.value = content;