Nano-IRC client in Forth

  • Permalink
  • submit to reddit
  • Email
  • Follow


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" ; 

1
Reply mhx (2134) 12/31/2006 7:41:57 PM

See related articles to this posting


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
Reply 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
Reply josv (129) 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
Reply 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
Reply 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
Reply josv (129) 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
Reply 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
Reply anton (5320) 1/5/2007 8:38:35 PM
comp.lang.forth 5927 articles. 3 followers. Post

7 Replies
1065 Views

Similar Articles

[PageSpeed] 30


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Win32Forth Nano-IRC client in Forth
Here is my socket library ported to Win32Forth (tested on vsn 6.10.04). After loading socket.frt you can test with .TIME-OF-DAY and .QUOTE (There's something wrong with Win32Forth's TYPE that I'm not going to fix :-) The latest file is irc.frt. I have verified that it works. This gives some confidence that there aren't too many bugs in socket.frt. Modify and enhance as much as you like, but please try to keep the functionality of socket.frt (names, stack diagrams, actions) the same. I did not try to add Bernd Paysan's httpd server as I still don't know how to do tha...

IRC client that handles irc:// URLs
Hello, I'm looking for an irc client that correctly handles URLs of the form: <irc://irc.server.com/channel> That is, if I'm on a web site like www.packetnews.com and click such a URL I'd like the IRC client to launch, connect to the server, and join the channel. Every app I've tried does not seem to respond. Thanks for any suggestions! ...

IRC client that handles irc:// URLs
Hello, I'm looking for an irc client that correctly handles URLs of the form: <irc://irc.server.com/channel> That is, if I'm on a web site like www.packetnews.com and click such a URL I'd like the IRC client to launch, connect to the server, and join the channel. Every app I've tried does not seem to respond. Thanks for any suggestions! ...

irc client for OS/2 and msn/icq client
Hi All, I was wondering if there is any decent IRC client for OS/2 that actually makes use of the PM. I have tried PMBitchX but its not really what I wanted (if I wanted to use a unix console based irc client I could have ssh'd to my unix server and run it that way!). Are there any ports of xchat to OS/2 PM? I had been looking for an msn client, I had tried the web based msn, but its too slow and annoying. I looked at dMSN, but this seems to have bugs too (downloaded it from hobbes). Its rumoured that someone was going to port Gaim over to OS/2, has anyone heard any news...

IRC client
hi i was just wondering whether it is possible to connect to an irc server from wothin the university or does the firewall preent access? Alistair Mckellar wrote: > hi i was just wondering whether it is possible to connect to an irc > server from wothin the university or does the firewall preent access? .... depends. .. -- << http://michaeljtobler.homelinux.com/ >> A reactionary is a man whose political opinions always manage to keep up with yesterday. Alistair Mckellar wrote: > hi i was just wondering whether it is possible to connect to an irc > server f...

IRC client
Anyone got a WORKING irc client sourcecode? Thanks Joppe ...

Can't keep my IRC connections stable with text-based IRC clients?
Hello. I replaced my old Netgear RT311 router last night with an old Linksys BEFSX41 (latest firmware v1.52.15). However, I am having problems keeping my IRC programs staying connected. After about every five minutes, they get disconnected. The router's firewall log had these lines: 2008-10-18 22:17:12 1586/TCP from [deleted IRC's IP address]:6667 to 192.168.0.22:1586 Invalid TCP packet received, dropping packet Note: Changed 192.168.1.xxx to 192.168.0.xxx so I didn't have to reconfigure the computers' IP addresses after swapping from an old Netgear RT311 router. From...

Warp Server 4, Ethernet, 386/25
Hello, I'm back from my experiments. I managed to get a Ethernet adapter, and I've successfully, via MPTS managed to connect to my LAN, the net, including dns configured, hostnames etc... The question is now, I have a 386DX25, and I don't find a good FREE (opensource, why not) FTP client, very lightweight to run successfully and reliably on this machine... Same question, besides EzIRC, which is not very good, can I use a good IRC client...even very simple, but intuitive and powerful, like BitchX for instance, in command line... Any news reader ? Mail client ? all li...

IRC client for HP49
Hello, everybody ! This message is to make all of you aware of the first release of IRC Prime, the first IRC client for HP49G, originally written by Thomas Rast (t.rast@freesurf.ch) : download it at : http://www.hp-sources.com/internetprime/english.html With that soft, which uses the TCP/IP stack library "Usinagaz" by Samuel Thibault (Hi Samuel !), you can chat on any IRC channel using any IRC server. To try it, you need to do masquerading on linux and share your internet connection with your HP49, or either connect your HP49 to a phone external modem. I'd love some feedback ...

IRC client / help..
Well, I've just decided to look into this IRC thing. I am a total newbie at this and have been searching high and low for an app with downloadable (.doc or .txt) files - or even a basic generic guide (something I can sit down and read). All without luck. Even my local bookshop (a pretty large 'Waterstones' in the UK) has nothing in stock, and only 3 in their database - none less than 5 years old! So far I've downloaded: *Colloquy *Conversation *ircle *Snak *X-Chat Aqua *ChatZilla plugin (Firefox) The only help files I've found so far are all web-based (a bit awkward...

IRC client for Ubuntu
What's your recommendations for an irc client to run on Ubuntu Gutsy Tribe5. May not be any tested yet, so working on the assumption if it works on 7.4 it should work on the beta. I'm behind a hardware firewall, but no problem pinholing. I don't need fancy colors or layouts. Just so long as it connects to the main servers and isn't going to fall over every five minutes. Cheers -- Rob - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://www.aspir8or.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Give me one good compiler and I can redesign th...

IRC client with Matlab
I have a unique situation that I wish to use Matlab to feed an IRC channel. I am using Matlab to process text and matrices that I wish to share with a very specific chat group and wish to do it using a timer in matlab 7. I have the timer set up and currently am copying the data to the clipboard where it can then be pasted to the chat client. I would like to shorten this up by having matlab write directly to either the chat client or to the irc channel. Has anyone attempted this before. I know there is the TCP/IP?UDP toolbox but am not sure if it would be of any use. Thanks ...

irc client in vb
I'm searching for an irc client code written in vbasic.I also want that client code includes the dcc transfer protocols.anyone seen any educational codes about this subject? Hi Lerdof, if you go to http://www.planet-source-code.com and do a search in the VB section (at the top inter IRC Client and on the right of that select the vb in the selection list. Take a look at the first project that shows up in the search results....Advanced IRC...think it's got a lot of what you're looking for if not all. if course source code is all there :-). Hope this helps. -- St�phane Richard...

Recommend IRC Client
I was looking at the Hobbes Directort of IRC Clients. Does anyone have any suggestions of what to try first? Is there one you like? Either shareware or freeware. PM rather than text. Thanks Paul -- On Sat, 30 Apr 2005 03:53:30 UTC, prschmi@Zverizon.net (PaulRS) wrote: -> I was looking at the Hobbes Directort of IRC Clients. Does anyone -> have any suggestions of what to try first? Is there one you like? -> Either shareware or freeware. PM rather than text. -> -> Thanks -> Paul Chatzilla - See http://www.os2voice.org/VNL/past_issues/...

IRC client library for Java.
Anyone know of any IRC client libraries for Java? I have a simple use-case, where an existing tool will send a note to a specific channel on a specific server when a specific event occurs. Nothing complicated really. One gotcha is that the IRC server runs on SSL only, so the library needs to support that. Thanks, Daniel. On Thu, 23 Aug 2012 11:40:53 -0700, Daniel Pitts wrote: > Anyone know of any IRC client libraries for Java? I have a simple > use-case, where an existing tool will send a note to a specific channel > on a specific server when a specific event o...

IRC client with Latex support?
Hello, does anybody know a irc client (for linux) that displays mathematical formulas? thx Paul M. skreiv: > does anybody know a irc client (for linux) that displays mathematical > formulas? Kopete does. It has built-in LaTeX support using a plug-in (installed by default), KopeTeX. -- Karl Ove Hufthammer E-post/Jabber: karl@huftis.org would emacs irclient be able to use preview-latex? David Rod -- ...

irc client with audible notification
hi, i've been using erc as an irc client within emacs21 on a debian woody machine but i need an audible beep or something when someone else puts a message into the channel. does anyone have this working - and which irc client are they using. thanks for any help, kev --=-=-= kev <deeval_oper@bigfoot.com> writes: > hi, > > i've been using erc as an irc client within emacs21 on a debian woody > machine but i need an audible beep or something when someone else puts a > message into the channel. does anyone have this working - and which irc > client a...

irc type client for AIM
Hey all, Was wondering if anyone knows of a command line (curses/ncurses) client like irc but works with the aol instant messenger service AIM? I've been looking around freshmeat & sourceforge for the past week and it seems like the only two non-java ones that possibly can work on a Solaris 9 box (sparc) are: centericq-4.21.0 -and- pork-0.99.8.1 But if there is a way to build those either with Studio 11 or gcc, you got me. Both have massive problems with paths, the ncurses stuff mostly but a crapload of other problems as well. The java stuff up there outright doesn't work, it...

pico-RSS client in Forth
An RSS reader in 220 lines. In case somebody is really interested I could provide a less iForth specific version. At the least, one needs a socket library and some string words. Just now, I need some sleep :-) The three feeds at the bottom work, but it is quite possible that some tags and HTML character escapes are missing and break the code. -marcel -- (* * LANGUAGE : ANS Forth with extensions * PROJECT : Forth Environments * DESCRIPTION : pico-RSS reader ( XML processor ) * CATEGORY : Example * AUTHOR : Marcel Hendrix * LAST CHANGE : January 6, 2007, Marcel Hendrix...

IRC client for Ubuntu #2
What's your recommendations for an irc client to run on Ubuntu Gutsy Tribe5. May not be any tested yet, so working on the assumption if it works on 7.4 it should work on the beta. I'm behind a hardware firewall, but no problem pinholing. I don't need fancy colors or layouts. Just so long as it connects to the main servers and isn't going to fall over every five minutes. Cheers -- Rob - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://www.aspir8or.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Give me one good compiler and I can redesign th...

Most powerful IRC client for Unix
What is it? BitchX? Ircii? -- Posted with a Jornada 720 Handheld PC running Ink Spot CE Usenet wherever you are - http://www.dejavusoftware.com/ [Jn 14:6] Jesus answered, �I am the way and the truth and the life. No one comes to the Father except through me. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- On 2006-01-27, Bible John <johnw_94020@yahoo.comPDA> wrote: > What is it? BitchX?...

Pexit: a multiprotocol IRC client
Pexit is a multiprotocol, multiplatform instant messaging and chat client. It supports all of the major messaging services, including ICQ(tm), AIM(tm), MSN(tm), Yahoo(r), IRC and RSS. Pexit has many features, such as whiteboards, multiprotocol chat rooms, chat history, alerts, auto-forward and reply, encryption and personal profiles. Pexit also performs peer-to-peer file transfers and can be connected to external databases to give them remote access. Pexit is available for all popular computer platforms. Pexit is written in Java, is plugin based and has an open architecture to acc...

New DOS IRC Client
The world probably doesn't need another DOS IRC client, but here it is anyway: http://www.brutman.com/Dos_Networking/IRCjr.html All you need to run is an 8088 class machine or better, an Ethernet card with a packet driver, and 256KB of RAM. (You can get it to run in 192KB fairly easily, but you will have to give up the backscroll buffer.) I've tested it with: - A PC XT with a 3Com 3C503 - A 386-30 with an NE2000 clone - A PCjr with a Xircom PE3-10BT parallel port-to-Ethernet adapter And a few other people have run it on other hardware .. I wrote the TC...

irc client for revo plus?
hey, is anyone aware if there's a (good) client for psion revo plus? i've been looking but still haven't found anything. e.s. etunimi sukunimi <etunimi.sukunimiTHIS_CRAP_IS_FOR_FILTERING_SPAM@salaliitto.com> wrote: > hey, is anyone aware if there's a (good) client for psion revo plus? > i've been looking but still haven't found anything. > e.s. Hi, you can try this : http://www.revosite.tap.pl/files/programyepoc/irc.zip pete ...