Witam, mam problem z podłączeniem się do serwera irc(próbowałem tego na portach 6665-6668, na różnych serwerach) - przy każdym połączeniu otrzymuję wyjątek: java.net.UnknownHostException: irc.pirc.pl
kod odpowiedzialny za połączenie:
package jirc.lib;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
import javax.swing.JTextArea;
public class IrcProtocol {
private static final int DEFAULT_PORT = 6667;
private Socket socket;
private InputStream inStream;
private String hostname;
private String msg;
private JTextArea textChat;
public IrcProtocol(String hostname, JTextArea textChat) {
this.hostname = hostname;
this.textChat = textChat;
Runnable r = new IrcConnectionThread();
Thread t = new Thread(r);
t.start();
}
public void setMsg(String s) {
if(s.startsWith("/"))
s = s.replace("/", "");
msg = s;
}
private class IrcConnectionThread implements Runnable {
public void run() {
try {
socket = new Socket(hostname, DEFAULT_PORT);
try {
inStream = socket.getInputStream();
Scanner in = new Scanner(inStream);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.write("user jIRC 127.1.0.1" + hostname + " :[email protected]\n");
msg = null;
while(in.hasNextLine()) {
String input = in.nextLine();
textChat.append(input + "\n");
if(msg != null) {
out.write(msg);
msg = null;
}
}
} finally {
socket.close();
textChat.append("Disconnect\n");
}
} catch(IOException e) {
textChat.append(e + "\n");
}
}
}
}