File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes IRC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "IRC" Watch "IRC" New topic
Author

IRC

Raja Islam
Ranch Hand

Joined: Dec 07, 2001
Posts: 74
Hi
i want to connect to irc using sockets but it is not workign my MIRC is working fine but there is some problem it output
:tiscali.uk.eu.dal.net NOTICE AUTH :*** Looking up your hostname...
:tiscali.uk.eu.dal.net NOTICE AUTH :*** Checking Ident
:tiscali.uk.eu.dal.net NOTICE AUTH :*** Found your hostname
ERROR :Closing Link: 0.0.0.0 (Ping timeout)
**************************************************
import java.io.*;
import java.net.*;
public class IRCConnection
{
private String host;
private int port;
public static void main(String[] args) throws UnknownHostException, IOException
{
new IRCConnection("212.74.101.21", 6662 );
}
public IRCConnection( String host, int port )
throws UnknownHostException, IOException
{
this.host = host;
this.port = port;
connect();
register();
}
private PrintStream out;
private void connect() throws UnknownHostException, IOException
{

Socket socket = new Socket(host,port);
out = new PrintStream( socket.getOutputStream() );
InputStream x=socket.getInputStream();
DataInputStream xy=new DataInputStream(x);
String line;
while((line=xy.readLine())!=null)
{
System.out.println(line);
}
xy.close();

}
private void register()
{
String nickname = "test";
String localhost = "localhost";
out.println( "USER" + " " + nickname + " " + localhost + " " + host + " " + nickname );
out.println( "NICK" + " " + nickname);
}

}
i think it is not problem of port cause MIRC is workign fine on same port.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: IRC
 
Similar Threads
Sockets vs URL Based classes
simple socket programming
Java client socket to talk to C server socket
How to Change the File Name for Each Uploaded Files to the Socket Server?
Client-Server Problem