M
M
MrPara2020-06-16 14:26:47
Java
MrPara, 2020-06-16 14:26:47

How to organize client interaction directly in Java?

Hello!
Now I plan to write a small multi-user application in Java, for educational purposes. Actually, the idea of ​​​​implementation is as follows:

  1. User #1 creates a room. At this time, only information about the room and data for direct connection to user No. 1 (host) are stored on the server, which now stores all the data that is planned to be exchanged
  2. User #2, #3 and #4 send a request to the server to get a list of rooms and then connect to the host
  3. Further, the data exchange occurs as follows: for example, user No. 2 performs some action, information about this is sent to the host and stored with it, and then sent to users No. 3 and No. 4


Why do this? Probably, in order not to place each room on the server and not pay for it ... Well, how can this be implemented using Java? What data is needed to connect users to each other? Perhaps there are some serious nuances? Perhaps I do not see or do not know something obvious? Would love some advice on these matters

PS Thanks in advance for your time :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
none7, 2020-06-16
@MrPara

The implementation itself requires only an understanding of the basics of network programming (socket, bind, listen, connect java.net.*). And the pitfall is huge. Clients, unlike servers, usually do not have globally routable addresses (white) or they are closed by a firewall. There are crutches like UPNP and NATPNP, but they don't always work. There is also the STUN technique (due to it, for example, torrent-utp works), but it will work less and less and does not work at all in mobile networks (as in other things, UPNP with NATPNP). With IPv6, a separate headache, because the address from which the client connected to the server may soon become invalid. A permanent address is better not to shine on the Internet without the permission of the user.
As a result, such an architecture can only work in local networks, since the modern Web does not like p2p very much.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question