开发者

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

开发者 https://www.devze.com 2023-03-17 15:51 出处:网络
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:

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 开发者_StackOverflowjava app receives the data sent, but continues to block waiting for more. I need to signal that this one line is the only input.


This link indicates you do

exec 3>&- 

Found using google. ;)


To close on the Java side

outputStream.close();
0

精彩评论

暂无评论...
验证码 换一张
取 消