CC.
CC.

Reputation: 2928

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 way to build a unix client ?

Upvotes: 0

Views: 291

Answers (2)

bjg
bjg

Reputation: 7477

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.

Upvotes: 0

nos
nos

Reputation: 229342

  • 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.

Upvotes: 1

Related Questions