How to test client- server architecture when using UDP? - java

I'm creating a small multiplayer game project using Java and I wanted to know if it were possible to test the client- server architecture on one machine. At the moment there is 1 client and 1 server, the client can send messages to the server as the server listens, then when the server responds to the client, instead of the clients listener reading the packet it gets looped back to the server.
Does anyone know how I can fix this?

Related

Java Socket Programming single Client-server

I want to create a simple chat program. But my requirement is some what different I want a single client - server type of thing. Means I don't want a multiple client server.
I am creating a server and waiting for client to connect. After client connects I am waiting for any message from client.
Now my problem is that when I run my client program, I can run multiple instances of it, but the only first client messages are delivered to server as it is single server client program. What I want is some sort of method with which I can limit other clients to connect and say display error message saying that server is busy try after sometime. Can anyone help me do that?
The server should have a list of all client connected so whenever a new client connect; instead of just adding a new client; it check if there is already a user connected and if yes ; it close the connection/return special exception.It is up to the client project you made that decide how it will handle this closing of connection/exception.

Android continuous tcp polling

I am working on a project in which I can see webcam images from the people who is in front of the door on my Android app.
But I am getting a bit confused. I've managed to setup a connection with a service on my phone to a server which handles the image sending.
But i only want to get images from the server when someone presses the doorbell, so I need to send a notification or something to my app so I know there is one in front of the door, and I want to decide if I want to answer his call or not.
Now this is why I am confused: if I open the tcp socket in the android service, how can I know that my server sends a 'call' message, because the tcp socket is openend when the service is created. Do I need to keep polling every second? Then there is still a little chance that I will miss the call message?
Or do I have to run the application as server and the doorbell as client, so the client request a connection?
Have a look at cloud to device messaging, c2dm , a lot more power efficient too. Built into android.
https://developers.google.com/android/c2dm/
If the tcp socket is opened when the service is created, just send some appropriate message from the server to connected clients. If your client is connected, it will get it. You only need to poll if the client continually connects and disconnects, eg. like many HTTP 1 web services.

Apache xml-rpc client and server implementation

I have been trying to figure out how to implement a simple xml rpc server and client with apache xml-rpc (http://ws.apache.org/xmlrpc/) but i haven't been successfull. I implemented a server and a client as specified here in the section Webserver: http://ws.apache.org/xmlrpc/server.html
The only thing i did differently was this "phm.addHandler("Calculator",org.apache.xmlrpc.demo.Calculator.class);" instead of this "phm.load(Thread.currentThread().getContextClassLoader(), "MyHandlers.properties");". When i start the server it start properly but I can't see the service when running netstat. Then when I run a request from the client it fails because it cannot find the class to call (i.e. the client doesn't really connect to the server). I have also observed that the client can start (not sending any requests) without any errors even when the server is not running.
Anyone have any ideas. I'm really lost.
Are you trying to run both client and server on the same computer? ...that may be the reason for netstat not working. (It cannot sniff packets on the loopback address.)
If you're still interested I can post a working example.

ActiveMQ debugging lost messages

I'm trying to use ActiveMQ in my application. In order to test it, I wrote two small Java applications, one acting as a Message Broker (server) and one application acting as a client. The client is able to publish messages to the server and they are supposed to be sent back to all clients (similar to a chat room chat client). It works all well between a few machines even across a VPN network, but a few clients act up funny. Especially one computer connects properly to the client and message sent from it will be sent to all clients, but it just does not receive message sent from other clients.
I am now wondering on how could I possibly debug this behaviour. I disabled the firewall on that machine, but I am still not able to resolve the issue.
Is there anything I can do to debug this in a convenient way?
Cheers,
Max

Server to Client Notification / Web service(jax-ws) to client communication

I am going to write a smart client application. This application will be swing based desktop client that will communicate with web service. I want to be a message has been sent to client from web service when any change occurs at server side file system. I wanted to use web services but I am not sure how I would implement a two-way communication between the server and client. Is it possible? If so how? If not what are the alternatives?
You have to program your client to be able to ping a request after a predefined frequency to check if there is a changes occurred on the server side. The client expect the changes occurred on the server or null if no change.

Categories