Nano-IRC client in Forth

Here it is: an IRC nano-client, with an extremely narrow purpose,
i.e. group-talk with people on #forth.

It's 85 lines of Forth, and needs a socket library (e.g. see my 
home pages).

For reference: the source code for ircll (text mode UNIX IRC client)
is around 1.64 MBytes of (C) text.

I tried to clean out iForthisms, but didn't test the code resulting 
from that operation.

The output to the console has a huge amount of address-info in front 
of each message, it would be nice to compact that to the nick of the 
talker. But for my own purposes, this version is usable.

-marcel
-- ----------
( *
  * LANGUAGE    : ANS Forth
  * PROJECT     : Forth Environments
  * DESCRIPTION : A nano-IRC client
  * CATEGORY    : Utility - check RFC-1459 for more functionality
  * AUTHOR      : Marcel Hendrix 
  * LAST CHANGE : Sunday, December 31, 2006, 14:12 PM, Marcel Hendrix; works for Linux with UTYPE 
  * LAST CHANGE : Saturday, December 30, 2006, 1:46 AM, Marcel Hendrix 
  * )

	DECIMAL
	NEEDS -sockets
	\ $+   concatenates two strings ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 )
	\ +CR  appends ^M and ^J control characters (network convention)
	ANEW -irc

0 [IF]
   Use socket API functions to perform IRC communication using TCP. 
   Connect to an (internally specified) IRC server, using predefined 
   REALNAME, USERNAME, and NICK strings.

   BUGS: There may be an "echo" when you resume HEAR after a SPEAK (text from other
         users typed during your absence is echoed prefixed with your nick).
[THEN]

\ standard tools --------------------------------------------------------------

0 VALUE lsocket				\ socket for IRC comms
0 VALUE #resp				\ response size
CREATE  response$ 512 CHARS ALLOT 	\ buffers response from server

\ Force interpretation of ^M and ^J (so they are the same in Windows and Linux)
: UTYPE		BOUNDS ?DO  I C@ EMIT  LOOP ; 				 ( -- )
: SEND$		lsocket WRITE-SOCKET ; 			        ( c-addr u -- )
: CMD		+CR SEND$ ;				        ( c-addr u -- )
: RECEIVE$	lsocket response$ 512 READ-SOCKET TO #resp DROP ;	 ( -- )
: ECHO-ALL 	BEGIN  RECEIVE$ #resp  WHILE  response$ #resp UTYPE  REPEAT ;

\ -----------------------------------------------------------------------------

6667 =: IPPORT_IRC 	\ standard IRC port address

CREATE server		," irc.freenode.net"
CREATE username		," mhx"
CREATE realname		," marcel hendrix"
CREATE nick		LINUX? [IF] ," BirdReynolds" [ELSE] ," gorgonzola" [THEN]

\ The server may challenge our vitality
: ?TEST-PING ( -- )
	response$ S" PING" TUCK COMPARE 
	0= IF  'O' response$ CHAR+ C! 
		response$ #resp +CR SEND$
		CLEAR #resp
	ENDIF ; 

: IRC-OPEN ( -- )
	server COUNT IPPORT_IRC OPEN-SERVICE TO lsocket 
	lsocket FALSE BLOCKING-MODE
	0 SET-SOCKET-TIMEOUT  RECEIVE$ 
	S" NICK " nick COUNT $+ CMD
	S" USER " username COUNT $+ S"  8 * :" $+ realname COUNT $+ CMD 
	S" JOIN #forth" CMD ;

: IRC-CLOSE ( -- ) 
	S" QUIT :a quit that really quits" CMD
	lsocket CLOSE-SOCKET ; 

: SPEAK ( -- )
	S" PRIVMSG #forth :" 0 WORD COUNT $+  
	CR ECHO-ALL CMD ; 

: HEAR ( -- )
	CR
	BEGIN 
	  RECEIVE$ 
	  ?TEST-PING
	  response$ #resp UTYPE
	  EKEY?
	UNTIL 
	EKEY DROP ;

: .ABOUT ( -- )
	CR ." Usage: IRC-OPEN    -- connect to #forth"
	CR ."        HEAR        -- listen what they say"
	CR ."        SPEAK text  -- write a message (text) to all on #forth"
	CR ."        IRC-CLOSE   -- disconnect from #forth" ; 

2
mhx (2135)
12/31/2006 7:41:57 PM
comp.lang.forth 6354 articles. 0 followers. markrobertwills (871) is leader. Post Follow

7 Replies
2187 Views

Similar Articles

[PageSpeed] 25
Marcel Hendrix wrote:
> Here it is: an IRC nano-client, with an extremely narrow purpose,
> i.e. group-talk with people on #forth.
>
> It's 85 lines of Forth, and needs a socket library (e.g. see my
> home pages).

Nice work!  That reminds me.  I think it would be really productive
if the Forth community could collaborate on a "FNL (Forth Net
Library) similair to how the FSL was built.  Perhaps if the "sockets"
wordset was used as a reference implementation with other
libraries built on top of it?

Regards,

John M. Drake

0
johnmdrake (128)
1/1/2007 4:31:41 AM
John M. Drake wrote:
> 
> Marcel Hendrix wrote:
> > Here it is: an IRC nano-client, with an extremely narrow purpose,
> > i.e. group-talk with people on #forth.
> >
> > It's 85 lines of Forth, and needs a socket library (e.g. see my
> > home pages).
> >
> > For reference: the source code for ircll (text mode UNIX IRC client)
> > is around 1.64 MBytes of (C) text.
> >
> > I tried to clean out iForthisms, but didn't test the code resulting
> > from that operation.
> 
> As an exercise I'm attempting to port this to another ANS Forth.
> I've chosen SP-Forth as my target.  (I tried Win32Forth, but the
> latest version of Win32Forth has an incompatibility issue that
> prevents it from loading it's own sockets.f library.  The offending
> word is &LOCAL.)

Add the following line at the start:
Synonym &local &of

Jos
==
4ePost: 844 bytes in mail. Elapsed time to buffer: .000088 sec.
0
josv (130)
1/3/2007 5:16:00 PM
Marcel Hendrix wrote:
> Here it is: an IRC nano-client, with an extremely narrow purpose,
> i.e. group-talk with people on #forth.
>
> It's 85 lines of Forth, and needs a socket library (e.g. see my
> home pages).
>
> For reference: the source code for ircll (text mode UNIX IRC client)
> is around 1.64 MBytes of (C) text.
>
> I tried to clean out iForthisms, but didn't test the code resulting
> from that operation.

As an exercise I'm attempting to port this to another ANS Forth.
I've chosen SP-Forth as my target.  (I tried Win32Forth, but the
latest version of Win32Forth has an incompatibility issue that
prevents it from loading it's own sockets.f library.  The offending
word is &LOCAL.)

I was able to find a lot of the non ANS words in the code such as
BOUNDS and ,".  I also figured out code for CR+ and +$ myself.
But there are still a couple of words I'm unsure about.

> 6667 =: IPPORT_IRC 	\ standard IRC port address

I'm guessing that's the same as:

6667 CONSTANT IPPORT_IRC

> : ?TEST-PING ( -- )
> 	response$ S" PING" TUCK COMPARE
> 	0= IF  'O' response$ CHAR+ C!
> 		response$ #resp +CR SEND$
> 		CLEAR #resp
> 	ENDIF ; 

What does "CLEAR #resp" do?
 
Regards,

John M. Drake

0
johnmdrake (128)
1/3/2007 5:43:07 PM
Jos van de Ven wrote:
> John M. Drake wrote:

> > As an exercise I'm attempting to port this to another ANS Forth.
> > I've chosen SP-Forth as my target.  (I tried Win32Forth, but the
> > latest version of Win32Forth has an incompatibility issue that
> > prevents it from loading it's own sockets.f library.  The offending
> > word is &LOCAL.)
>
> Add the following line at the start:
> Synonym &local &of
> 
> Jos

&of doesn't work either.  I'm using version 6.10.05 build 2.

0
johnmdrake (128)
1/3/2007 6:50:27 PM
John M. Drake wrote:
> 
> Jos van de Ven wrote:
> > John M. Drake wrote:
> 
> > > As an exercise I'm attempting to port this to another ANS Forth.
> > > I've chosen SP-Forth as my target.  (I tried Win32Forth, but the
> > > latest version of Win32Forth has an incompatibility issue that
> > > prevents it from loading it's own sockets.f library.  The offending
> > > word is &LOCAL.)
> >
> > Add the following line at the start:
> > Synonym &local &of
> > 
> > Jos
> 
> &of doesn't work either.  I'm using version 6.10.05 build 2.

It should work with Win32Forth V6.11.10
That can be downloaded from:
http://sourceforge.net/project/showfiles.php?group_id=55294

Jos
==
4ePost: 688 bytes in mail. Elapsed time to buffer: .000076 sec.
0
josv (130)
1/3/2007 7:04:35 PM
Jos van de Ven wrote:

> It should work with Win32Forth V6.11.10
> That can be downloaded from:
> http://sourceforge.net/project/showfiles.php?group_id=55294
>
> Jos

Thanks.  I've made the changes and it works now.  I also
got rid of REL>ABS and ABS>REL to stop all of the
irritating "Warning REL>ABS is a deprecated word"
messages.  I've uploaded the new file to the Win32Forth
Yahoo group.

Regards,

John M. Drake

0
johnmdrake (128)
1/4/2007 4:36:37 PM
mhx@iae.nl (Marcel Hendrix) writes:
>I tried to clean out iForthisms, but didn't test the code resulting 
>from that operation.

iForth has a feature that reports non-ANS words (that feature is
annoyingly on by default).  It might help for such cleaning jobs.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
Forth-Tagung 2007: http://www.complang.tuwien.ac.at/anton/forth-tagung07/
EuroForth 2007: September 13-16, 2007
0
anton (5320)
1/5/2007 8:38:35 PM
Reply:
Similar Artilces:

client ftp
Exist t he(it) of the examples of customer ftp with an interface graphs j would like to have some documentation before throwing(launching) me in the creation d a binary win32 with tclkit ...

Nano
What's the veredict on Nano? I don't have much space on my hd, and Vim is over a meg. thanks In article <Pine.LNX.4.61.0412031916130.2336@localhost.localdomain>, <Lugidigi@yahoo.net> wrote: >What's the veredict on Nano? I don't have much space on my hd, and Vim is >over a meg. > >thanks Mork says hi! Lugidigi@yahoo.net wrote: > What's the veredict on Nano? I don't have much space on my hd, and Vim is > over a meg. > > thanks You might want to try "ne" ( nice editor ): http://ne.dsi.unimi.it/ ...

Using Matlab as a client with com objects
I have a method in a com object that returns a vector of doubles. The size of this vector is set by 'size is(Size)' where Size is an input parameter. The problem is, Matlab 2006a seems unable to deal with 'size is', and always expects one double to be returned instead of a vector. Which of course crashes it. The method is ... [id(6), helpstring("method GetAbsolutePositions")] HRESULT GetAbsolutePositions([out,size is(Size)] double* Positions, [in] long Size, [out,retval] long * pReturnedSize); Is there a way of getting Matlab to work correctly with this type of com ...

MS Network Client for Dos V3.0
From a DOS workstation with "MS network client for DOS v3.0" installed I'm trying to connect to a network share in our DMZ zone. I'm able to connect from the DOS workstations to other network shares without the firewall in between. Our firewall is a Checkpoint firewall. When I look in the firewall logs traffic is passing to the DMZ zone (nothing gets dropped). On the Dos workstations I get error 53 network path not found. When I connect to the network share using XP or Win2000 it works fine. The Server in our DMZ zone is a Windows 2000 Server. What could cause ...

Possible to create folders in Nano manually and have Nano browse them?
Greetings, I was wondering if there's a way for me to be able to created folders in Nano such that when I choose the "Songs" menu, it will show the folders I had created? If not, is there a way so that Nano will recognize the folders I make and is able to go into them which would contain music files and play songs that way? I wish to be able to do so that I can manually categorize the songs myself, instead of Nano doing it for me based on the meta info it receives from the song files. The playlists and the genre feature Nano has is alright, but it'd be nice if I can creat...

socket client using -myaddr
Using TCL 8.5.5, I have an application that creates multiple interpreters and each interpreter attempts to create a client socket on a specific interface: The problem is that the first interpreter works, but the additional interpreters fail with: couldn't open socket: address already in use while executing "socket -myaddr 192.168.1.10 $host $port" (procedure "connect" line 40) invoked from within "connect 192.168.1.40 7001" If I exclude -myaddr then all works fine and all the connections still use ...

writing a web client
I want to write a program which will automatically login to my ISPs website, retrieve data and do some processing. Can this be done? Can you point me to any example python programs which do similar things? Regards, Ajar Ajar wrote: > I want to write a program which will automatically login to my ISPs > website, retrieve data and do some processing. Can this be done? Can > you point me to any example python programs which do similar things? > > Regards, > Ajar Very easily. Have a look at my article on the ``urllib2`` module. http://www.voidspace.org.uk/python/articles.sh...

java agent wil not print in log.nsf and sometimes crashes client
hi, i have a problem.... domino client 6.5.2 and a java agent. this agent runs periodic and should print into the log.nsf .... System.out.println("System-OUT"); .... sometimes it workes sometimes not, sometimes it chrashes the workstation (with nsd... see attached parts). any ideas? rds mk parts from the nsd: ############################################# FATAL THREAD 20/21 [ntaskldr:06a0:0390] ### FP=0x0d52fbc8, PC=0x60190201, SP=0x0d52f050, stksize=2936 ### EAX=0x00e2088c, EBX=0x00000000, ECX=0x008f0000, EDX=0x008f0000 ### ESI=0x0d52f75c, EDI=0x00000049, CS...

#CBM8 on IRC NEWNET CHAT TIME
Hey everyone, Tired of waiting for replies on usenet? want real time chat with commodore 8 bit fans?? Grab an irc chat program like Mirc and come join us on Newnet, channel #cbm8 Dragos is giving away free commodore stuff to people who message him there!! How cool is that?? Cya there!! -- Leo Im looking for Commodore 64/Vic20 Cartridges! Got any? Check out my tradelist & items for sale at http://www.commodore64.allhell.com yes, i will give anyone there, any piece of gear that Kilr donates. ...

#python IRC help
Hi. Not sure if anyone can help here, but I'm trying to access #python and have found out that my ISP has a blanket ban (for some reason). Does anyone know how I can contact an operator to join? Thanks. What? Sounds a bit unlikely unless its Virgin.. I'd imagine it might be that your isp needs to get itself off a black list. Brian -- My Hotmail Account mildew_spores@hotmail.com "simonh" <simonharrison.uk@googlemail.com> wrote in message news:fd0bd7d3-ad1d-43c2-b8e5-642a95c21f78@t26g2000prh.googlegroups.com... > Hi. Not sure if anyone can help here, but I'm t...

Looking for a doc on AP/client connection process
HI, Can anyone point me to a doc which explains the initial connection process between an AP and client ? I had a look at some how-to's but they don't answer my questions. Somoething that addresses my questions below would be good. Thanks, Ray. When a client powers up, I guess it listens on each channel for an AP beacon, and then lists the available APs to the user ? When initiating a connection with an AP, I guess the client sends out a connection request to the AP ? This request might be a DHCP broadcast and must include MAC address, and SSID of AP ? What happens if 2 APs with the...

Is there a Netware client for Solaris?
I wonder if there is anything like ncpmount/ncpumount from Linux on Solaris (allows mounting of Netware server volumes)? -- Regards, Jaroslaw Rafa raj@ap.krakow.pl -- Spam, wirusy, spyware... masz do��? Jest alternatywa! http://www.firefox.pl/ --- http://www.thunderbird.pl/ Szybciej. �atwiej. Bezpieczniej. Internet tak jak lubisz. ...

starting a client remotely
I am playing with multiprocessing and I would like to have a python script on one machine which initialize my whole system, in other words, this script should start the server (a python script) on my local machine and the clients (python scripts) on the other machines in my local network. Would you have any suggestion? regards, jacopo jacopo wrote: > I am playing with multiprocessing and I would like to have a python > script on one machine which initialize my whole system, in other > words, this script should start the server (a python script) on my > local machine and the cli...

Netgear FVS318 and ProSafe Client setup
Hello. I'm new to this group, and I'd welcome any directions. I have an FVS318 from Netgear, and the Prosafe VPN client software. I'm interested in proving the client's ability to be used on a laptop (remote), and get it to phone home to the FVS318 (main headquarters). However, Netgear offers NO technical support without a price. what's really unique is that the settings on the client don't necessarily reflect the settings on the router. That's the part that really surprised me... it's like it's designed to confuse. I also willfully admit t...

nano itx
The beginning of the end of desktop clutter and the dawn of lower gross margins for Apple. Apple better do some R&D where it counts, like VIA, and not wrapping the innards of a powerbook in a small plastic case and sell it for 500 US. http://www.ncasia.com/ViewArt.cfm?Magid=3&Artid=26751&Catid=1&subcat=1 Nicolas In article <ngKee.8824$Ph4.258244@ursa-nb00s0.nbnet.nb.ca>, NashtOn <nana@na.ca> wrote: > The beginning of the end of desktop clutter and the dawn of lower gross > margins for Apple. > > Apple better do some R&D where it counts, li...

HELP! Need to buy Laptop for a client
Dear All, Have spent the evening with a client trying to sort out a laptop purchase but don't seem to have got very far! The laptop will be used mainly for using office 2000 (word in particular) and also as a backup to his desktop machine. So as a minimum spec should be at least similar to his desktop machine: Athlon XP1800+ 256MB Memory 80GB Hard Disk (could come down to 30GB on this) Windows 98SE! He also wants a minimum of 2 USB ports, modem and a CD-RW drive in it. My client is happy with a second hand machine (if I'll stand by it, i.e. fix it for him!). He wants to use ...

Connection specific DNS suffix not assigned to VPN clients
Hi, I have a Cisco PIX 515e firewall and have set up a PPTP VPN connection which works fine, except that the connection specific DNS suffix is not passed on to the client machines when they connect to the VPN and are assigned an IP address. We are using WinXP clients with the standard MS VPN client software. When I manually enter the DNS suffix into the advanced TCP/IP settings everything works correctly. Any assistance would be appreciated. DNS suffix is left blank (shown below) PPP adapter XXXX VPN: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : WAN (PPP/SLIP) I...

US-NY: Scarsdale-Sr. Client-side Software Developer
************************************************************** JobCircle.com is a regional job board serving all industries and occupations in the PA, NJ, DE, NY, MD, and DC areas. We offer a regional job board, online learning, and regional job fair events for jobseekers who live in our areas of focus. To Learn More: Job Board: http://www.JobCircle.com?source=ng eLearning: http://www.JobCircle.com/courseware?source=ng Job Fairs: http://JobCircleJobFairs.com?source=ng ************************************************************** Job Title: Sr. Clie...

Excellent Siebel Consultant Available for your Direct Client reks
SUMMARY: =B7 Overall 9+ years of total IT experience =B7 4+ year of experience on Siebel Server Administration , Configuration and Application Development =B7 Dynamic, results oriented Team Player with extensive experience in Siebel Server Administration =B7 Worked as Consultant ( Siebel) , Software Engineer (Siebel), Computer Analyst (NT and System Admin ) =B7 Administration Experience on Siebel, Microsoft Windows & Networking =B7 Experience as team leader and system support analyst. =B7 IT Exposure - Siebel CRM Server Administration, Application Development ,...

kaffe with nano-X gui
hi all, I compiled kaffe 1.1.5 with the AWT backend for Nano-X. I'm getting a very weird behaviour: if I start a demo (just open a window and set a green background) it starts with no errors, and stay there: 1 time in (about) 30 the windows appear on the LCD: the other times I do not see nothing!!! (same behaviour wit another program: both programs on PC works perfectly) Does anyone have an idea of what can cause such a behaviour: why the program starts correctly just sometimes? Could be some race condition in the VM? How could I proceed to investigate and understand what...

Notes 6.0 Client Not Showing Holidays
I have a single user who currently is not able to display any holidays. If we try and reload the holidays, the system says it is already loaded. How can I get the holidays back into this person's calendar? Thanks in advance for your help. ...

Scientific Computing and Forth
When I first read Skip Carter's assertion on the FSL page that Forth may be= a strong contender for the replacement of Fortran, for the scientific comm= unity, I have to say that I was a bit incredulous. Over the years, however,= I've come around to that idea, as I used Forth for various computing tasks= .. I believe the primary obstacle to extensive use of Forth for scientific c= omputing has very, very little to do with the debate over standards. ANS Fo= rth, with its flaws, is very well suited for scientific computing. The prim= ary problem, as Skip Carter noted, and tried ...

FAQ Topic
----------------------------------------------------------------------- FAQ Topic - How do I get a perl/asp/php variable into client-side js? ----------------------------------------------------------------------- Use the server-side language to generate the javascript: var jsvar="<%= aspvar %>"; var jsvar="<?php echo $phpvar ?>"; === Postings such as this are automatically sent once a day. Their goal is to answer repeated questions, and to offer the content to the community for continuous evaluation/improvement. The complete comp.lang.javascript F...

Writing an IRC bot in Haskell
Hi I'm writing an IRC bot in Haskell. So far I've used this guide: http://www.haskell.org/haskellwiki/Roll_your_own_IRC_bot, but I'd like to extend the bot a bit further. I've tried looking on Google for other tutorials with little result. Does anyone have any suggestions for Haskell networking or IRC bot tutorials/howtos/guides? I've been playing around with Haskell for just a few weeks, so I'm not very good at it, and I understand an IRC bot isn't the best project for my expirience level, but I want to write something useful at the same time as I lear...

Tracking down rouge clients across WAN links.
I have CISCO routers and switches everywhere. I am currently seeing on my firewall logs, due to default routing, ICMP traffic to and from US military IP addresses. I have used Ethereal and tracked both source IP's as coming from one of my Cisco routers which connects many remote locations. I have telneted into each of these remote locations and did SHOW ARP and SHOW IP CACHE and see no reference to the rouge IP's. In the old days, I'd take over these remote machines and packet sniff on the hubs. But I am in a switched network and there are too many remote locations. I do hav...