tcp connection from unix to java
I'm looking for something,I don't know if it exists.
I have a Java server, something like
while (true) {
try {
Socket socket = server.accept();
new ConnectionHandler(socket);
System.out.println("Waiting for a new client message...");
} catch (IOException e) {
e.printStackTrace();
}
}
What I need, is to do a unix client to connect to this server. I need only to send a message, and my server will launch a process. Is there a开发者_Python百科 way to build a unix client ?
At least for testing, you could use telnet to connect to your service, and issue text commands.
Netcat could be used as well, just give it the IP address and port where your Java server is running. e.g.
echo "My Message" | nc 192.168.1.42 10001
Build your own client in Java.
If you don't want to develop a client in Java you could consider the unix nc (netcat) command. It's a veritable swiss-army knife of TCP and UDP.
精彩评论