Solved

How to create a Delphi IRC Client?

Posted on 1997-11-16
2
641 Views
Last Modified: 2010-04-04
Is there any way to create a delphi IRC client, I would like to find out how... thanks a lot!
0
Comment
Question by:sqz
2 Comments
 

Accepted Solution

by:
mgrendel earned 110 total points
ID: 1350660
Firstly, get the RFC specifications for IRC.  These are available at www.internic.com.  Then I would suggest you get dWinsock; a great shareware Winsock component package ( available at www.aait.com/dwinsock ).

After installing the components,  create an IRCChatClient of type TTextClient ( dWinsock ); ie.,

                         IRCChatClient : TTextClient ;

Then create a connection method, something like:

procedure MainForm.btnIRCConnectClick(Sender: TObject);
begin
   if not (IRCChatClient.Connected)  then
     with IRCChatClient  do begin
        Address := Server.Text;  { irc server address, using a
                                                 TEdit named Server }
        Port    := Port.Text;          { irc server port as a string i.e                                                   '6667', again using a TEdit }
        Open(TLineSocket);        { open the connection as a                                                             TLineSocket }
     end;
end;

This will establish a connection.  Using the RFC's, send the login info, which are 2 strings:

     "USER <nick> <localhost> <localIP> :<real name>"
      and
     "NICK <nick>"

Use something like the following procedure ( you'll need to declare a TMemo somewhere on your form to hold the text -
ChatArea : TMemo ; ):

procedure TForm1.IRCChatClient.Connect(Sender: TObject;                                                                Socket: TSocketBase);
var
   LocalIP : ShortString;
   sLogin    : string;
begin
     if Socket.Connected Then
       begin
          ChatArea.Lines.Add ( 'Connection accepted ...                      Logging to IRC server');
          LocalIP := IRCChatClient.LookUpAddrByNameStr                                        ( IRCChatClient.LocalHost ) ;
         sLogin := 'USER <nickname> ' + IRCChatClient.LocalHost                          + ' ' + LocalIP + ' ' + ':<real name>'#$A + 'NICK '                          + <nickname>';
         (Socket As TLineSocket).WriteLine(sLogin);
         Exit;
       end
     else
       begin
         ChatArea.Lines.Add('Error while connecting to server...');
         Socket.Close;
       end;
end;

That will get you started.  Use the RFC's to build a parser, ect to control your client.  Note you will need to PING alot - to keep the thing connected ;)

Hope that helps.
0
 

Author Comment

by:sqz
ID: 1350661
great help! let me know if you have any sources etc.. thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now