Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am building an application where in the requirement is that, there is a main server, which will send signal to client server, based on this signal the client performs certain action and send back the response to the main server. Here there will be only one main server and can be multiple client servers. At a given time the main server can send multiple signal to multiple clients.
I am presently planning to do this using socket programming in Java using two ports. Do let me know the best way of achieving this? and also do we have any good existing API's that can be used?
Take a look at RMI: https://docs.oracle.com/javase/tutorial/rmi/ If you want something based on sockets/TCP/UDP/etc, writing something with Netty may be good solution -> http://netty.io/ (they have useful examples).
I would also recommend to consider plain Java Sockets if planned communication beetween server and clients is not comlex and you do not need all this stuff which is provided by libraries like Netty.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
So usually, to have get and set methods in networking Java I use an enum, for example:
public enum MyEnum {
GET_NAME,
GET_ADDRESS;
}
etc. which the client application and server application would send between each other as a string and the appropriate task would be carried out.
I wanted to know how applications do this usually? What data do they send through the socket to make the program work, do they use ObjectStreams? Do they send bytes?
Wanted to know what the best practice would be to have a client-server setup for my own messaging application.
EXTRA INFO:
The client / server network I'm designing is for a PLUGIN in a GAME and therefore has to be instant / speedy ;)
All of that. Or something else.
The "industry" standard can be many things, depending on the domain you are looking at, or the decade when the solution was designed.
In 2018, most "new" client/server communication that gets defined doesn't operate on socket level. You rather define a set of restful APIs that the server offers, and data flows as JSON strings for example.
In other words: the official answer here is: there is no such as an industry-wide standard. To the contrary: what you are asking about (sending individual comments on socket level) is probably the exception, and not something that is common for real world architectures. People don't think in sockets and single commands. They think in terms of protocols, abstractions, maybe "remote procedure calls".
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm creating a simple java application made in swing that communicates with a database. Multiple people will be using the application at the same time. As they are able to change things at the same time, if someone for example, adds a new user, and a different person is on that same page, I want the person who did not make the change to be notified that changes were made to the database since they last loaded it.
My lecturer in college advised me that WebSockets would be the way to go to achieve this, however after some reading about WebSockets in Java, it seems it is based to work with web browsers instead of between Java applications.
Can using WebSockets achieve what I am trying? Or, if not, what would be a way to achieve this?
Simple answer is Yes you can achieve what you needed
WebSocket is a communication protocol(#see RFC 6455) & it is not a must to use a Web browser.
You can achieve what you want to do with your app, it is just a matter of writing a custom WebSocket server to facilitate your requirements in your case sending database changes to the other clients(Which is called Server push)
There are several java libraries to get the work done,
netty WebSocket (My favorite)
jWebsocket
Atmosphere
Webbit
Netty WebSocket is a good one to start with and you can find examples in its project to write a custom client and a server
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
What is the best way to transmit data between two (Java) applications running on the same machine? One obvious idea would be to use standard Sockets but this doesn't feel right.
I've heard that most operating systems have a built-in system specifically for this task. How is it called and how does it work?
And is there any other good method to do something like that?
I think it depends on what you want to communicate between the applications and the size of your project. Some examples:
Sharing of state - use a database, files or similar
Messaging - use a socket. On top of a socket you have several technologies you can leverage, like HTTP/REST, but you can also create your own transport
There are also message applications you can leverage, like RabbitMQ
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am exploring various ways that allow Java to connect and communicate with NodeJS. An example of what I am trying to achieve, is for example call Java methods from NodeJS, while allowing the Java method to manipulate Javascript objects. I know the JSObject class is helpful for this purpose. I have also heard so far of Dnode and ZeroMQ. Have you heard of or do you have experience in doing something similar? Would you suggest a way on how this communication Java to NodejS can be done?
I would go with an agnostic implementation.
A rest server on node js, maybe using restify listening for messages
A http client on the java side as httpclient to send messages to node.
this will also make it dead easy to test node implementation with curl and static requests; will enable you to implement authentication later on using any standard mechanism from oauth to basic and will let you change the client and the dispatcher independently later on
also you will be able to put any kind of standard load balancer in between, should you need the node app to scale.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I went across all the links on java Inter Process Communication, but I couldn't get an exact answer. I am on my way to write a java service which I want to communicate with a service running on my system. The service may be C, C++, or a service running on a hardware device. Which is the best way? Is it possible to use RMI in this case? If yes how can I implement that?
RMI is generally designed for interprocess communication between Java applications. If you need language-agnostic technology, currently the most popular are webservices (SOAP or REST based) or CORBA. But as the other service is going to work on "hardware device" they may be too heavyweight in which case you could think of your own communication protocol eg. based on TCP/IP connection.
You can go through online tutorials on CORBA with JAVA technologies. You can also refer oracle documentation for the same
Refer http://docs.oracle.com/javase/1.4.2/docs/guide/idl/jidlExample.html