java library: socket communication between 2 or more java applications
-
14-01-2021 - |
题
I'm looking for a java library that help me send information between 2 or more running java applications that are on the same or different machines(different networks).
I'm looking for a TCP socket communication.
I know I can implement my own format, but I'm looking for something already done.
I'm also looking for something simple that is not resource hungry.
Thanks
解决方案
java.net.Socket plus java.io.DataInputStream and java.io.DataOutputStream.
RMI.
RMI/IIOP.
XML-RPC.
JAXB or any other implementation of SOAP.
And that's not exhaustive.
其他提示
To do simple socket communication in Java, the built in libraries are fairly straightforward: See http://www.oracle.com/technetwork/java/socket-140484.html
In terms of the format of data to send across the socket connection. One way to go is Java serialization, but I would not recommend this unless you know the exact environment you're running on as it is not a very flexible/portable way to go. Instead, maybe take a look at something like google-gson (http://code.google.com/p/google-gson/) which is a low-profile, easy-to-use library for encoding from Java class instances to Json and vice-versa. Json is a very portable format and you can use it with almost any language/platform.