
WriterChannel.write("JOIN " + channel + " " + channelPassword + "\r\n") // Join a channel WriterChannel.write("USER " + login + " 8 * :" + login + " \r\n") WriterChannel.write("NICK " + nick + "\r\n") If (line.indexOf("004") != -1) // If connectedĮlse if (line.indexOf("433") != -1) // If Nick already in use WriterChannel.write("USER " + login + " 8 * :" + login + " \r\n") // Join IRC with a specific User WriterChannel.write("NICK " + nick + "\r\n") // Join IRC with a specific Nick

String line, computerName, nick, login, channel = "#bot", channelPassword = "" ĬomputerName = ().getHostName() SSLSocket socket = (SSLSocket) socketBuilder.createSocket("", 6697) SSLSocket socket = (SSLSocket) socketBuilder.createSocket("127.0.0.1", 4000) Ī simple IRC example: import java.io.BufferedReader SSLSocketFactory socketBuilder = (SSLSocketFactory) SSLSocketFactory.getDefault() Socket socket = new Socket("127.0.0.1", 4000) Īlso take a look at: import While ((line = readerChannel.readLine()) != null)Ī simple client example: import java.io.BufferedReader WriterChannel.write(new Date().toString() + "\n\r") 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.
