Access a server from outside local network [closed] - java

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

Related

How does Bungeecord/Lilypad send players to other servers [closed]

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.

How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game? [closed]

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 2 years ago.
Improve this question
I am working on a game and I am thinking about getting into networking. I have been programming for about 5 years and got into game development the last 2 years. I only really learn online and from books on my own time. I am planning to make a java server for Amazon AWS EC2, but I am just wondering how MMO's handle multiple players each tick.
Is it just the sheer power of servers? I am not looking for code or anything, just in general how the servers work.
Does the server just do all of the calculations for all of the players and the tens or hundreds of thousands of objects and then send and receive thousands of packets every tick? It just seems like a lot for a single computer to handle, but it is indeed a server.
How work and what is the job of a server?
Your server create a socket and open a port.
The protocol for an online game is generally in UDP because it is faster.
Your server have to handle ALL the clients connections.
You can add a server who is able to log an account and redirect him into a game server (this is the case for all the big MMO).
Your server have to manage all the calculations from the Data Base: when an enemy hit another enemy, subtract a part of your money when you buy some stuffs...
So the server is the main part of an online game.
In fact, a computer is really fast for do some calculations, the most heavy part for a modern video game is the physics and graphics... Fortunately, these both parts are on the client part.
But, a server have to be strong! Not like a client because he doesn't need a big GPU, but he need a big amount of RAM/CPU (depend of the game) and he also need to stay cold.
In fact, a game server is able to handle a large amounts of connections because of the UDP protocol and because all the heavy parts of the program are on the client side. You can take a look here: Creating a Multiplayer game in python and read the part when I explain the difference between the UDP and the TCP protocol.
All the others informations about how work an MMO server are linked at the end of this topic.
Now we can try to build a server!
Firstly, do you know how to create a server?
Program or download a server for do a test (example: TeamSpeak or Mumble).
Launch him from your computer and allow his input connections from your firewall.
Log you on your modem and forward/redirect the port of your server into your computer.
For the last part, you need to do some research: Which port is used by my server and how to forward a port with my modem (each modem is different).
Now you can try to log you into your server. But...!
Your computer have three IPs:
The Loopback address: localhost, 127.0.0.0 (The "0" can change)
The Intranet address (IP linked to your computer): 192.168.0.0, 172.16.0.0, 10.0.0.0
And the internet address (IP linked to your modem): 0.0.0.0
How to know your Intranet/internet IP? That depend of your Operating System and your modem. For the Intranet use your terminal and write "ifconfig" or "ipconfig". For your internet address, it is sometime write when you log you to your modem, or you have to visit a website who is able to show you your IP.
If you create a server and you didn't forward the port from your modem, you can still access to your server in local with your Loopback address and the others computers connected to the same modem can also access to the server with the Intranet address. Also, if you need to test if your server is accessible from internet, you have to test the connection with your internet IP, but some modem don't allow the externals connections from the Intranet... So if your connection with the internet IP doesn't work, try to log you to your server from another modem (friend's PC, Cyber-Coffee...).
Lastly, how to protect your server?
This is really difficult and you cannot create a perfect security... Especially if you follow my advices but you didn't complete my knowledge with your own research.
Root access
This is the most important part. When a lamer try to access to your server, he can just try a simple connection like the http/ssh/ftp. If he can access to your hard disk and you haven't chose a strong restriction, he can simply read/modify/delete the Data Base of your game. The Data Base contain all the informations about the accounts.
Firewall
We have already talk about the amount of connections/calculation than a server have to handle. In some attack, the lamer try to create a big amount of connections and didn't close them. We call that a DOS (with 1 computer) or DDOS (more than 1 computer). So you need a good firewall for: allow only the port of your server, allow only X numbers of connections from an unique IP and allow only X numbers of new connections every minutes.
Updates
This is the easiest part: keep your Operating System (and the others applications) up to date.
Less is better
Don't install many useless software to your server. If a software is not import for your server, you shouldn't install him because: firstly, that can be a virus. Secondly, a malware can exploit this software for install a virus or steal the root access.
Encryption
The encryption is really important for block an Hacker. For example, with the https protocol you can protected the user's passwords from the MITM attack. And with the Bluefish/SHA/others, you can encrypt your Data Base for protect her even if an Hacker can read it. The most important is always to block the write/modify/deletion/execute right of the Hacker (in fact, all the clients of your game need the read access).
Anti-virus?
In the case of an online-game, an anti-virus is not really important (But still recommended for all Operating System, Linux/Unix also).
Have a good server
If your server is programmed without take care of the security, you can be in trouble. Example: Buffer Overflow attack in C/C++.
If you need more informations about how work an MMO, I recommend you:
http://electronics.howstuffworks.com/mmorpg6.htm
https://en.wikipedia.org/wiki/Server_%28computing%29
https://en.wikipedia.org/wiki/Game_server
https://www.quora.com/How-do-I-create-an-MMORPG
Hint - If you are interesting by create an online game, you have to do many research, I cannot really answer in this question because is not the purpose of the subject. And this subject is too large for write a new answer at each question... Which software use for program a game? How to build a socket? Where started? But I have already answer at some similar questions. Even if the programming language are sometime different, I give you the link, the logic is always the same so it can maybe help you:
Creating a Multiplayer game in python
Xcode Mass Multiplayer (Not What You're Probably Thinking)
Multiplayer game in Java. Connect client (player) to game that was created by other client
Most MMO's have a healthy amount of client logic so that the server doesn't need to send multitudes of packets to every player all the time. The server doesn't do calculations for all players, the client does the heavy lifting and the server deals with the clients and the state of the virtual world in a database.
For example, your client and server could have the same world model. That way your player can navigate the world and the client code tell the server on a fairly course interval (say 100's of msecs).
Generally you want your clients to update themselves to the server, and have the server response deal with keeping the clients in sync.
MMOs also run multiple servers in their farms, from tens to hundreds. These servers typically talk to a large high-performance database - basically the state of the virtual world is in the database, and the servers sit in between keeping the database up to date and communicating to the client apps.

Java Socket Programming LAN Messenger [closed]

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).

JAVA sockets client to client communication [closed]

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.

Java Multicast sample program is unable to deliver packets within LAN (across hosts) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am learning and trying to understand how Multicast is implemented in Java. I had developed a small program following the example given at http://www.nmsl.cs.ucsb.edu/MulticastSocketsBook/#javaexamples and it did do multicast of datagram (UDP) packets to multiple clients on same host.
However when I tried to run clients on different machines (within same LAN (i.e. my home WiFi) no packets got received at client end. I made sure that my router's firewall was disabled as well as all other machines had a port open.
Thinking my program could have some error, I took the examples, compiled them and run server and client on different machines but same result (no packet delivery to different machines). I even tried running client on Ubuntu (within VirtualBox with Bridge Adapter) but no luck.
After going through SO, I came across Java Multicast Time To Live is always 0 explaining the problem with TTL header in Java multicast. So I applied the suggestion provided in that question's answer but still same problem. I tracked the packets with WireShark and verified that TTL had indeed value 5 (I set it to 5 to widen the probability !)
I am not sure where I am doing wrong. I would really appreciate if you can point me into right direction.
P.S. : I had used multicast addresses like 235.1.1.1 / 239.255.211.111 and port 4466 (this port I kept open in firewall of all machines for inbound + outbound n/w)

Categories