If creating an IM platform in Java, which would be a better way to implement communications between the clients and server?
I was thinking either RMI or just a socket connection...
Advice please,
Thanks
I would use straight socket connection, using a well known protocol such as XMPP. You can use a library (like smack) to avoid implementing the whole protocol yourself.
The main advantage of XMPP over RMI or your self-made protocol is that is a well established protocol used for exactly that purpose: IM.
Some chat services already using XMPP include Google Chat (GTALK) and Facebook.
I already did this using Smack API, using XMPP protocol.
CometD has been specifically designed for use cases such as Chatrooms. Differently from other protocols, it works over HTTP port 80, which means (nearly) no hassles with Firewalls.
Listen to a recent podcast with Greg Wilkins about the project, which goes into some details of issues with implementing Chatrooms and how it gets handled by CometD.
I believe there is a Java client for CometD if you need to have client on both sides of conversation (normally frontend is JavaScript).
Related
I am extending custom written windows based server (c#). Currently server provides two commnication interfaces (SignalR based, and simplified TCP protocol based). Both interfaces work well with windows clients which i also wrote.
There is a new requirement that server should communicate with native Android (java) client. Communication should be bi-directional:
-> server should be able to push data to client
-> client should be able to push data to sever
Can you recommend any usefull communication solution?
It Man.
Have you considered JSON over HTTP2?
In HTTP2 you can do a server push which allows bi-directional communication. That being said, often bi-direction communication between a client and server like this is implemented with a polling model.
Another option might be GRPC which allows streaming connections on top of http2. It often uses proto as the serialization format but doesn't have to.
Those two might be worth checking out.
I'm developing a Desktop LAN base java server and client application
where a Client must login and also to pass some data to server.
assuming i have 10 clients that inserting record simultaneously to server.
which is the best approach in this kind of situation, should I use RMI for login and record insertion? or Sockets?
if sockets please provide a key idea for me to start with.
key points to consider
-Multithreading
-able to send back data on client
If you want to connect your server via internet (and/or firewalls) it is probably a hassle to do this with plain RMI. In the past I have used Java Simon for such tasks which is very easy to implement. However if you plan to support other clients than Java clients, then you should have a look at Apache Thrift or Google Protocoll Buffers
my question is following up from this question:
Simple Protocol Concept in Java for this setup
The idea is exactly the same i.e client will send request and server respond with some information:
However i want a well known protocol implemtation such that the server/client can be implemented in any programming langguage. So that client Running java can communicate over TCP/IP sockets to remote app written in C e.g.
for this reason, can you recommend any well known opensource implementation?
Just few tips:
Rest interface: http://en.wikipedia.org/wiki/Representational_state_transfer
Corba: http://en.wikipedia.org/wiki/Common_Object_Request_Broker_Architecture
Apache Thrift: http://thrift.apache.org/
Google Protocol Buffers: https://developers.google.com/protocol-buffers/
your own implementation over tcp...
it depend on your architecture and your requirement, you can use TCP protocol directly, Http is another choice, if your server deployed on a http server, i recommend using web service. i hope my answer will give you some ideas.
I'm making client-server app and we've chosen Netty as a connection management framework. We use SSL TCP connections. As of now, the client is also being made on Java. But in future the project should support mobile devices: Android and iOS.
The question is: how painful is to implement C++ or Objective C client connecting to Java server on Netty?
You could use CocoaAsyncSocket, I have used it as a client with server that implemented in Netty using a protocol I have defined that will send and receive data as JSON and it's as good as Netty.
It really depends on what protocol you are using. If you define a protocol where you are sending serialised java objects as binary like this then you will trouble writing a client in a non JVM language. If you use a text based protocol (see here) or a HTTP based web-service then it will be easy.
I am building a android clients - single server application, and want to use JSON objects for communication. Will have some simple database on the server. what would be a good scheme for server side implementation. Here are my options:
Socket programming - then can I still use HttpClient on the android client?
HttpServer - I heard it is not working well with android, and how do you do multithreading on server side?
any other recommendation would be helpful. thanks
There is some interesting discussion over at this SO question that may provide some useful info: How to call a SOAP web service on Android