David Parks
David Parks

Reputation: 32071

What can I send to an InputStream to signify EOF has been reached?

In a server app I am listening on a socket and reading using an InputStreamReader.

The client is a simple Bash script, in which I do the following to write to the socket and print the output from it:

#!/bin/bash
exec 3<>/dev/tcp/localhost/9999
echo -e some_text >&3
cat <&3

I wold like to indicate EOF after I send my data via echo, as-is the java app receives the data sent, but continues to block waiting for more. I need to signal that this one line is the only input.

Upvotes: 2

Views: 2221

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533500

This link indicates you do

exec 3>&- 

Found using google. ;)


To close on the Java side

outputStream.close();

Upvotes: 3

Related Questions