Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good Java networking library? [closed]

I'm currently searching for a Java networking library. What I want to do is sending XML, JSON or other serialized messages from a client to another client and/or client to server.

My first attempt was to create an POJO for each message, plus a MessageWriter for sending and a MessageReader for receiving it. Plus socket and error handling. Which is quite a lot of error prone work.

What I'm looking for is a a higher level library which abstracts from sockets. Furthermore it should supports something like code generation for the messages.

Google's Protocol Buffers (http://code.google.com/apis/protocolbuffers/) looks promising. But are there alternatives? The emphasis is not on speed or security (at the moment), it is just supposed to work reliable and with a low amount of implementation time.

like image 361
Stefan Teitge Avatar asked Jan 05 '09 18:01

Stefan Teitge


People also ask

Is Java good for networking?

Java is the first programming language designed from the ground up with networking in mind. As the global Internet continues to grow, Java is uniquely suited to build the next generation of network applications.

What is TCP in Java?

The java.net package provides support for the two common network protocols − TCP − TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically used over the Internet Protocol, which is referred to as TCP/IP.

What is reserved socket in Java?

The sockets which are reserved by specific protocols for communication are reserved sockets. Once the connection is ready a higher-level protocol is in use. This is dependent on the port which you are using. TCP/IP uses or reserves the lower 1024 ports for specific protocols.

What are network libraries?

The Network library makes it possible to read and write data across machines on the Internet. It allows the creation clients and servers. A server connects to a list of clients for reading and writing data. A client is able to read and write data to a server.


1 Answers

You have several options depending on how abstracted from raw sockets you want to get. Once you depart from socket level programming, you're pretty much into remoting territory,

  • Standard Remoting Options for Java: RMI or JMS
  • Implement JMX Mbeans in each client and the servers and use JMX remoting to invoke message passing operations.
  • If you think you might want to use multicast, I would definitely check JGroups.
  • If you're looking to create your own protocol but want to use some existing building blocks, check out Jakarta Commons Net. The HttpClient referenced in Answer #1 has been incorporated into this package.
  • There are also some interesting proprietary messaging systems that have the added virtue of supporting multiple platforms/languages such as Spread and DBus.
  • Can't enumerate remoting options without mentioning WebServices.... but.... blech!

I am not completely sure what you mean by code generation for the messages. Can you elaborate ?

like image 107
Nicholas Avatar answered Nov 09 '22 22:11

Nicholas