Mega Code Archive

 
Categories / Delphi / Examples
 

Quick BNC

Title: Quick BNC Question: How do you do BNC for IRC and other TCP/IP protocols? Answer: How do you do BNC for IRC? Well my method is quick and simple, its not perfect but it'll get the job done, and it "could" be used on anything not just IRC but also HTTP, FTP, MSN Messenger, Yahoo Messenger, AOL Messenger, ICQ and more! Firstly BNC basically is a bouncing method, much like a proxy, you connect from your local machine to a remove bounce machine which then passes data on further to the final destination. This article assumes you have Delphi and TServerSocket, TClientSocket components - the principals however can be applied to other TCP/IP socket components. 1) Create a new application, blank form et al. 2) Drop 1 TServerSocket component on the form and 1 TClientSocket component on the form. 3) Set the TServerSocket port and the TClientSocket port to 6667. Set the TClientSocket host to lineone.uk.eu.dal.net. 4) In the OnRead event of the TClientSocket create the following code: procedure ClientSocketRead(Sender: TObject; Socket: TCustomWinSocket); var Data: String; I: Integer; begin Data := Socket.ReceiveText; for I := 0 to ServerSocket.Socket.ActiveConnections do ServerSocket.Socket.Connections[I].SendText(Data); end; 5) In the OnClientRead event of the TServerSocket create the following code: procedure ServerSocketClientRead(Sender: TObject; Socket: TCustomWinSocket); var Data: String; begin Data := Socket.ReceiveText; ClientSocket.Socket.SendText(Data); end; 6) On the Form's OnCreate put the following code: procedure FormCreate(Sender: TObject); begin ServerSocket.Open; ClientSocket.Open; end; 7) On the Form's OnDestroy put the following code: procedure FormDestroy(Sender: TObject); begin ServerSocket.Close; ClientSocket.Close; end; Compile and run. Once running quickly launch for example mIRC, type: /server localhost 6667 It will then route via the BNC to the IRC server. You can put the BNC anywhere! Of course this is only a rough job, real BNC stays alive when you disconnect your client (this one sort of will) and knows when you rejoin etc. This can also be extended to cover HTTP proxy etc. Enjoy!