Im trying to make a test chat program written in java to be able to send and receive messages. It works but to receive them you have to open the ports on your router. How can i get around this?
You cannot without implementing a third party server which routes the chat between the two clients. This server would have the required incoming ports open, and would just forward everything.
Related
I want to develop network application (servers-clients) with some process:
server creating instance on specific port and sending to other client in network information about existance (can be invitation message);
clients are checking about existing servers in LAN network on specific port. Choose which one to connect and do other actions.
I tried ServerSocket and Socket and I know how to connect one server to one client. But to do procedures described above I need to do something like broadcating. Which method should I use and try? Is MulticastServer good for that one?
Thanks for help.
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.
I am trying to write a piece of software that
accept simple UDP messages (text strings) from simple UDP client,
opens connection to another server and forwards messages to it
listens for that server reply and
forwards that reply back to the client.
So it is a simple intermediate server.
To visualise the communication:
Client <---> Intermediate Server <---> "Real" Server
The client connects to the Intermediate but has no idea that the message it sends is being forwarded to another server, or that it's reply is actually from another server. As far as the client cares it the Intermediate server is the real server.
I am trying to use Java's DatagramChannel for this, but not quite sure how to correctly do this in a non-hack way. Do I use two DatagramChannels? One for Client--Intermediate and the other for Intermediate--Real Server?
An general outline of approach would be appreciated, particularly if I need to open a socket every time I need to forward a message from the Intermediate to the Real Server, or if I can keep that socket open somehow.
You only need one datagram socket for this, and you can keep it open for the life of the process.
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
I want to program a game that involves a client-server option for a network.
For this, I need to be able to get a list of all people that are hosting a server on their computer but the Socket class requires a name of the computer. Is it possible to get this list and if so, then how?
Thanks you very much
You could use a MulticastSocket on the client to listen for broadcast UDP packets from the server. See Broadcasting to Multiple Recipients and have your server send one out every few seconds.