Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create a Delphi IRC Client?

Posted on 1997-11-16
2
Medium Priority
?
731 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 440 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

877 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