ServerSocket listener = new ServerSocket(4000) īufferedReader readerChannel = new BufferedReader(new InputStreamReader(socket.getInputStream())) īufferedWriter writerChannel = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())) Public static void main(String args) throws Exception I have add an example in Java at the end of this post.Ī simple server example: import java.io.BufferedReader You can also take a look here Creating a Multiplayer game in python, I give an example where the clients was able to connect them together with IRC and play at a Tic-Tac-Toe game (so you didn't have to manage a server). ![]() You can create two majors kinds of network:īut a client can save some data to the server and the server can send them to all the clients (you don't need a Peer-to-Peer network for allow the Client B to send some data to the Client A).Įxample: The Client B send his map position to the server, the server send the data to all the clients, so the Client A is able to draw a character tileset at the position of the Client B.įor connect two PCs together, you need to forward a port from the modem of your server to the PC used as server, and open the port from the firewall of the PC used as server. ![]() ![]() Another client cannot be connected to the Client A because of his firewall.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |