2

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.

David Parks
  • 30,789
  • 47
  • 185
  • 328

1 Answers1

3

This link indicates you do

exec 3>&- 

Found using google. ;)


To close on the Java side

outputStream.close();
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • That would be done from the server end. I need the bash shell script to indicate to the server that it's finished sending data. – David Parks Jul 04 '11 at 10:14
  • On the server we have: while( (input=inputReader.readline())!=null ), I need readLine() to return null, which it does when it encounters EOF. What I'm trying to figure out is how to send it the EOF marker from the Bash shell script. – David Parks Jul 04 '11 at 10:15
  • This link indicates you do `exec 3>&-` http://tldp.org/LDP/abs/html/io-redirection.html – Peter Lawrey Jul 04 '11 at 10:19