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 working on Lan Messenger, how can I check if somebody else's system has LAN plugged in?
Means, is that person Online?
Also, our hostel has LAN, and I've tried running the client server program a lot many times, but it runs fine on my system (2 clients on the same machine as server) but it doesn't run when server and client are on different machines.
The code is perfectly fine.
What could be the reason? Any special Firewall settings to be changed for allowing packets?
I'm creating a chat server using sockets right now and the way I'm doing it is I have every user query the server about every 20-30 seconds. The server keeps track of the last time a user "refreshed" itself. If a user's gone a certain time period or more without doing so, then the server tells anyone trying to contact this user that they are offline.
Here is a VERY good reference to work off of. Take a look at the Server folder for the server-side and the src folder for the client-side:
https://code.google.com/p/simple-android-instant-messaging-application/source/browse/trunk/#trunk%2FServer%253Fstate%253Dclosed
If you only want to communicate within a LAN, then the socket implementatation in that link is defininitely what you want. If you want to communicate globally( a user in 1 LAN to a user in some other LAN ) then you'll want to redesign it a little so that your server socket is actually on some server accepting client connections. The current implementation creates a server socket within each client and accepts connections from other clients trying to communicate with it. This design breaks due to NAT routers (for reasons I'd rather not explain unless you really want to know).
Related
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
I am developing an app where I should be able to remotely access laptop camera's using my app. But how do I write a socket programming as I am new to android, I don't know if by just using Java socket programming is it possible to access laptop cameras
There is a Socket class and a ServerSocket class in Java. You give both of the clients sockets and have them connect to the ServerSocket. If you're remotely connecting to the laptop from your Android device from a different network, then you may need to set up a server to host the ServerSocket part on. Google App Engine can help with that. It also lets you deploy your Java app directly to the app engine via a plugin in Eclipse.
You need to write a simple tcp server-client application, as soon as both devices are on the same network is going to work like charm...
on the Android:
The client which must search and find the server (in this case the pc)
on the PC:
a server client waiting for the android (actually waiting for a tcp client)
As soon as both connect, send some formatted string that will be predefined by you and interpreted by the server as Commands...
with those commands try to turn-off/on the camera, disconnect the app, take a picture etc etc
if you look properly you will find 10000 of examples of java tcp server clients...
good luck!
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
Ok, so I am a little bit stuck with this problem and could really use some guidance...I have a java application that I have written in Java on eclipse and I also have a database created in mySQL on the same computer, now say I want to copy my java application to another computer on a different network but connect to that same database on my original computer on mySQL, what modifications do I have to make so I can connect to my database on different networks and areas? any guidance or help would be greatly appreciated. Beginner in Java and Databases so please try to explain thoroughly.
Since you use a pure JDBC application you simply need to set the JDBC URL to match with your requirements knowing that the format is something like:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
So assuming that your hostname is foo and the port is 3306, the first thing that you will have to do is to change the current JDBC URL of your application for something like jdbc:mysql://foo:3306 (assuming that your host is accessible from the other computer and you configured your firewall to accept connections on the port of your database).
More info here
For the second part of the job to do (assuming that you have a static IP address), you will need to configure a port forwarding rule at your internet modem level such that any access to your public IP on a given port will be directly routed to the local IP address of your machine on the mysql port. Check the documentation of your modem to know how to do such thing. Here is more info about port forwarding
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
So I previously asked a question if you can send a client that's on a ServerSocket to a different Server. But now, I'm asking how are the players for minecraft sent from server to server using Bungeecord and/or Lilypad. I know that LilyPad uses proxies and that stuff, but how are the players, when connected to the Bungeecord/Lilypad server, sent to a hub/spawn and/or to other servers, for example a survival server and a creative server. You can find servers like this on servers that have networks. I know that Treasure wars uses lilypad, if that helps.
You answered your own question. Both Bungeecord and LilyPad are proxy server networks.
Though a server cannot redirect the client to another server without permission, the server can connect to another server (meaning the first server is a proxy) and send back that server's messages to the client. As the first server is, in essence, also a client to the second server, the first server can switch connections at any desired point.
In other words, the Minecraft client does not switch connections at any point. The IP of the server to which the Minecraft client is connected never changes, and it is that of the proxy. However, what does change is the server to which the proxy is connected. If the client sends some message to the proxy stating that it wishes to go to the hub, the proxy then disconnects from whatever server it is currently connected to, connects to the hub, and sends back to the Minecraft client whatever messages the hub responds with.
This is my understanding based on a quick search.
However, if the Minecraft client was modded as well, it would be possible to have a similar network without the need for a proxy like so:
Client interacts with the server in such a way (maybe the player walks into a portal) as to trigger some server-switching action.
The server recognizes this interaction and, as both it and the client are modded, knows how to respond. The response is simply the sending of a message to the client, saying, "Switch to a different server. Here is the IP: (Insert IP here)"
The client receives the message from the server and, by its own will, disconnects from the current server and reconnects to the new one.
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 was planning to create a chat messaging application wherein two or more clients can communicate but I am a little confused.
Does java can have a client to client communication using sockets?
Does the socket communication always needs a server?
Is it possible that one client will stand a server of the communication?
Do you have any tutorials for a client to client communication?
If the communication needs a server, how a can a client A see Client B's messages?
Client to client communication does not makes any sense because once a system start receiving message it is termed as server, so in communication there should be a server and client to communicate else the situation will be like two people talking and none of them listening.
Client A can act as a server and client both and so the client B,
in doing so both can communicate in two way ie send and receive information.
Yes, java can work with sockets.
For example, an "official" tutorial from Oracle: http://docs.oracle.com/javase/tutorial/networking/sockets/
But working with sockets directly requires a lot of code for encoding/decoding message from/to a binary form, separating data stream to logical "packets", handling threads and message queues, etc. Fortunately, there are network libraries which make this process much more easier. I would recommend Netty: http://netty.io/
About client/server relationships. If we are talking about TCP/IP, then yes. One side (server) always listens for connection, and the other side (client) opens a connection to the server.
If you are using UDP, however, from network point of view, all participants are equal. They just send and receive UDP packets.
Back to your chat application: the most simple solution - all clients connect to the dedicated server. Every chat message contains client id. When the server receives the message, it sends it to the client with the specified id. Thus, every client can transfer message to every other client. The server works as a "dispatcher".
If you need simple approach you can try https://httprelay.io service. What you need is just http client and no external libraries.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a server written in Java which basically awaits requests from different clients and serves their requests. I am running this server from Eclipse. This server is accessible on the local network but I want to be able to access this service from outside the local network. Is there any way to do this please?
P.S. I am a real beginner in these things
you can open a port in the router that leads to the one that the server is listening on. You then connect to your public IP. This ip can be found on
As #Java Player said, the problem is that your router(Nat) denied any incoming packet to your local network...briefly, there is many solutions for this:
Third party server: you must have a dedicated server that plays the role of intermediary, between your client/server programs.
Pros:
Solve completely the problem related to the Nat.
Cons:
In addition of your client, you must code another third party that forward packet to the desired destination.
BTW it gets a little heavy(waste of bandwidth).
Reversed connexion: the server and the client program are reversed, that's mean the client become a server and the server become a client, 'used by most of trojan...
Pros:
Very easy to implement this approach.
cons:
You must at least has an opened port.
Udp hole punching: this approach is used by perhaps all peer2peer solutions(eg: skype, utorrent...).
Pros:
You don't need to any router configuration.
Direct connection between peers.
Cons:
You need also a third party server called STUN server to get informations about your router.
Not all router that works with udp hole punching, you must consider also the first solution.
Writing a hole punching solution is not easy task.
You could also download something like Hamachi and then download Hamachi and sign into your network on the other PCs and Macs (and Linux...which is currently in beta). Then you'll want to be able to access your server on.
Main Hamachi product page
Linux Beta