Developing an application for communication between computers in a network - java

I need to develop a software application for a computers in a network in the following scenario:
Computers in a network are monitored by another master computer running a controller program. The controller is a software appln which performs network discovery, gets data from the discovered computers and performs a set of operations on the discovered computers.
I have made progress until this level:
1. Program for network discovery. o/p is IPs of all the active machines on n/w.
2. Basic program implementing RMI(rejected sockets as the program might have diff implementations)
My doubts:
1.Assuming that I need to send the instructions of operation to be executed on client machines with diff IPs, how do I do it with RMI? How do I connect to other clients,in the first place using RMI?
2.After connecting, how do I transmit instructions to and fro the controller?
Please help me out!

You might try reading the JNDI tutorial. It covers aspects of discovering other computers and communicating them at a level that may be useful to your project. The tutorial is located here: http://download.oracle.com/javase/jndi/tutorial/trailmap.html

Related

Cross-platform server application to communicate with Android/iOS on WiFi

I am working on an application where I need to establish a server on a Windows/Linux/Mac machine which will need to communicate to an Android/iOS device over an existing WiFi network.
I am just in the research phase for now, and though I can find answers for communicating between PC-Android, PC-iOS, Mac-iOS etcetera, I cannot find an answer using which I can do all of it.
The mobile application will be different for both the platforms, of-course, but the server application should ideally be the same, and should be cross-platform.
I should also mention that the server and the clients(mobile-apps) will maintain a 1:n relation, meaning that several Android/iOS devices will be communicating with the server at once.
I need advice on which language/library shall I use for the server which would let the it communicate to both the mobile platforms.
Advice on the libraries I should use for the mobile platforms will also be helpful, though it's not important until I complete the server.
I am just looking for links to helpful resources, though I will be very grateful if you share some code.
I shall also mention, I know Python/Java/C++ which I can use for the server, but you are open to suggest another language which may make the work easier.
EDIT: What I forgot to mention is that, this will be a local server, that is, it needs to communicate with these devices on a LAN (devices on the same wifi network).
If you Know Java for the server side you cab create an application that hosts a RestFull API running on a tomcat server that you call with a local address (such as http://ip_adress:port/appname)
Tomcat can run on Windows, Linux or Mac.
If you need more informations just ask

Need to call from jxfs client to jxfs server

I am very new to jxfs things. I have a requirement to call jxfs server which is in cloud server from the jxfs client which is in ATM environment.. How can i call?.. I need to call this one through the Jxfs RMI concept. It would be appreciated one if any example code is available. If atleast you are having code for calling from jxfs server to jxfs client, please post it.
Thanks in advance guys.
One of the interesting things about J/XFS and remote device access (based on RMI) is that it is just matter of configuration.
You need to configure a J/XFS repository in order to handle a remote device (basically set 'remoteAccess' to true).
Then accessing these devices from the programming point of view is just the same as they were local devices.
Architecture is explained here: ftp://ftp.cencenelec.eu/CWA/CEN/WS-J-XFS/cwa14923/cwa14923-01-2004-May.pdf
Details, when programming may differ depending on the J/XFS implementation you are using.
Trying to answer your question below:
Whenever you want to access a device remotely in J/XFS, RMI is used. You need to make the following setup:
On a server (should be accessible) you need to start a JxfsServer. The JxfsServer will use a Read.repository
whith all the ATM's and devices configured on them as workstations, with the right IP addresses.
On the ATM, you need to install:
J/XFS libs
J/XFS device services for the devices on the ATM
Setup the DSstarter:
Will use the SpecificDeviceManagerRMI connecting to the JxfsServer you started before.
On your server (cloud) wherever you are going to use the J/XFS client you can get the remote controls by performing
the J/XFS initialization as follows:
jxfsDM_ = JxfsDeviceManager.getReference();
jxfsDM_.initialize("com.jxfs.forum.communication.rmi.SpecificDeviceManagerRMI,<atmWorkstation>,AppTest,2006;<jxfsserverhostname>,");
Then you can get the remote device controls with getDevice(...), and start using them as if they were local devices.
Please, note that handling RMI ports can be tricky, specially in a secured environment as ATM network. Make sure all the ports you need are open.

Need clarification of LAN application concept

Recently i developed a simple chat application in java using sockets. It was working fine. But now i want to make an application which can communicate over the Local Area Networks like IPMSG. The features will be
message sending.
file sending.
voice chat.
group chat.
encryption/decryption on demand.
These were the basic features to be included.
Now the confusion i am facing over here is
The application is an peer to peer application in which one user can do anything what other users can do.
There is no centralized server and there in no client. Every node acts as a server and client both.
So the application has to be peer to peer. But when i googled it then i am getting samples like client-server only and when i talk to my peers regarding this then also they suggest me the client-server model but there is no justification for why client-server and why not peer to peer. Am i right in this case ? Can anyone please guide me in this case because once i start development on any of these concept i cannot revert back due to time shortage. Your suggestions are most welcome.
I think the main reason a server-client relation is advised, is to make it easier for logging, or make a large chatroom for everyone (like IRC). If there is a login required, the server would also verify the login details. So without a server in between, phishing attacks would become more difficult to deal with.
I don't see why a P2P chat wouldn't work, though. If I recall correctly, Skype is doing that. I always love decentralizing. Good luck with your project. :)
You might want to check out the Zeroconf standard and packages that use it like Avahi (linux FOSS) or Bonjour (Apple & Windows open-source but not GPL). Zeroconf allows for configuration and detection of network services without user interaction or a central configuration server.
I end up using a client server model modified to support to P2P networking. When a node comes into the network it broadcasts its presence and the other nodes are continuously listening for new nodes. Each node will have their own list for the connected nodes in the network. In case of new node coming into the network they will update their own lists. I am using UDP for all most all the operations except file transfer as it needs to be in TCP.

Push message to AIR app from Java Server

I am looking for solutions for a problem that we are facing. We are planning to make a POC for Desktop Alert application. We will have a desktop AIR app that will connect to a Java Server. The server will need to notify Desktop App when it has a notification which will be displayed on the screen.
A couple of options that we have discovered are :
1. Keep a persistent connection between the AIR app and the Server, using some sockets and listen to any changes.
2. Poll the Server at intervals to check if some new data has come.
Since these options don't seem optimal (persistent connection) or seems performance wise (polling) better.
Is there a better solution for this problem or do we have to choose one of these?
For this, you could use a BlazeDS message service if you want to push messages to your client. Or a regular remote service with polling enabled.
It is built in out of the box and well tested equipment :)
Other technologies like GraniteDS or WebOrb for java are also possibilities.
Cheers

Run program on remote PC using Java

I am creating an application in which I have a central (server?) PC.
When at a particular position (or event) in the central PC, a XML file is dumped. The program reads that XML in which remote PC IP is given (any PC).
The command is transmitted to that PC, that PC will execute that command.
The command may be one of various types and for each command that PC has a separate class file.
Per command it will create an object of that type and run the desired method.
Question: What is the best technology with which I can implement this architecture?
Ok, what is your question?
The simplest way to do this may be to use RMI.
However, have you considered using a JMS queue as this would allow you to distribute the work evenly across many PCs without having to allocate a specific PC to a specific task. i.e. you give a queue the tasks you want to perform and the next available PC performs that task.
Take a look at Java RMI
Obligatory Wiki link and quote and why this can apply to your implementation:
The Java Remote Method Invocation
Application Programming Interface
(API), or Java RMI, is a Java
application programming interface that
performs the object-oriented
equivalent of remote procedure calls
(RPC).
(even across machine boundaries)
RMI is also the first that came up in my mind. But I think to give a really good answer we need some more details about what is done on the remote PC. My guess is that you are building a distributed Worker Thread Pattern
Other options can be:
JMS.
Web Services.
Etc.
You have several options.. You can use RMI, you can have a JMS Queue/Topic or even a Http Pub/sub. Each one of these has pros/cons.
With RMI, you can make the remote PCs open a connection to the server on startup to avoid the firewall issues. This way you only need to open the incoming/outgoing ports only on your central PC.
With JMS, you can register a listener from each of the remote PCs to a Topic/Queue opened by your JMS container. Any message you put in the Queue/Topic, you have a message filter set by using IP that way the message will only go to one targeted PC. I like this approach because of the lose coupling between your remote PCs and Central PC. But in this approach, since you don't have an open connection between your remote and your central pc, your Central PC will not have the similar control that you would get in the RMI system.

Categories

Resources