Solved

How to create a Delphi IRC Client?

Posted on 1997-11-16
2
682 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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