r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
18-Jan-2010
[1643x3]
http://rebol.wik.is/Rebol3/Schemes/Imap4
Updated to version 0.0.2 
Logs into Imap server using cram-md5 if available
Switches to inbox
gets inbox status for unseen messages
Retrieves the first 3 messages
As Andreas notes, a write to the port inside the awake handler is 
fine .. but outside the handler, you have to do a wait on the port 
to do anything.

Also i found that without using a timeout value, it doesn't work 
for me 

So, I removed the 'read cmdport from write-cmdport function, and 
put the wait instead in the actor 'read ...
with a timeout
Graham
19-Jan-2010
[1646x8]
I've got the imap protocol to the point where
1. can authenticate using cram-md5 ( reused r2 code )

2. can select different mailboxes ( unlike r2 where you have to select 
at time of opening the port )
3. length? 
4. Pick messages

However, I don't like this timeout which is there ..
2010.01.19 22:43:38 LOG5[4624:1256]: stunnel 4.29 on x86-pc-mingw32-gnu 
with OpenSSL 0.9.8l 5 Nov 2009

2010.01.19 22:43:38 LOG5[4624:1256]: Threading:WIN32 SSL:ENGINE Sockets:SELECT,IPv6

2010.01.19 22:43:38 LOG5[4624:5260]: No limit detected for the number 
of clients

2010.01.19 22:43:38 LOG3[4624:5260]: Error binding imaps to 0.0.0.0:993

2010.01.19 22:43:38 LOG3[4624:5260]: bind: Permission denied (WSAEACCES) 
(10013)

2010.01.19 22:43:38 LOG3[4624:5260]: Server is down
using run as admin
time to read the manual :(
I thought yahoo had free imap service .. but can't find it now :(
Nope ... not free.
Looks like AIM still has free IMAP ... signing up again!
Signed up, sent myself a couple of emails to that account, and then 
managed to login and download using the imap protocol
Pekr
19-Jan-2010
[1654]
Graham - you are becoming a networking Guru :-)
Graham
19-Jan-2010
[1655x2]
Nah .. this stuff isn't at all hard.  Carl made scheme creation much 
easier than in r2
I suspect that the amount of detail put into making a bullet proof 
http scheme frightened everyone off!
Pekr
19-Jan-2010
[1657x2]
yes, probably ...
Any thoughts on the unification process of error handling, logging, 
timeouts, etc.?
Graham
19-Jan-2010
[1659]
Well, Carl is going to have to look at them .. but since my  schemes 
use the same method ... they are pretty unified :)
Carl
19-Jan-2010
[1660]
So, where's the best place to start... the one that best shows the 
basic template?
Graham
19-Jan-2010
[1661x2]
smtp I think ...
though that one is an early effort
Carl
19-Jan-2010
[1663x3]
So, not Daytime?
Graham: During your "journey" through this .. did you notice if there's 
a standard template that would make sense for various parts of the 
implementation?
Also, where and how would you like to see my comments?
Graham
19-Jan-2010
[1666x3]
I started with daytime, moved to smtp, and then ftp, fax and now 
imap.  I am using pretty much the same template with changes appropriate 
to the protocol.
I think docbase ... is the place
Daytime is too trivial to learn much from ... maybe FTP instead??
Carl
19-Jan-2010
[1669x2]
Ok.


My question above is whether there's a standard "core" that can be 
used across many protocols... a bit like net-utils or default protocol 
on R2.
I'll go with SMTP for now.  Looks simple enough.
Graham
19-Jan-2010
[1671x3]
The only standard stuff I use is ...
1. net-log
2. some parse rules and bitsets
3. some authentication stuff like cram-md5


I also stack the commands sent to the port and pop them off as the 
port is async ...
I do this in ftp, fax and imap .. but I should go back and do this 
for smtp as well
I was thinking of using net-log as a way to hook into the low level 
activity of the protocol so that I can patch it as needed when interacting 
with a GUI ... eg, for progress meters
Carl
19-Jan-2010
[1674]
Ok, good... then I'll start with IMAP... since it's more recent.
Graham
19-Jan-2010
[1675x2]
One thing that is not clear to me is that if you write to the port 

eg. write imap-port [ dialect stuff ]

and then 
wait imap-port


it can return immediately ... and you don't get anything unless you 
put in a timeout

eg. wait [ imap-port timeout ]
Ok, let me upload the latest version ....
Carl
19-Jan-2010
[1677]
Isn't that dependent on what you return from awake?
Graham
19-Jan-2010
[1678x3]
in wrote there is a 'read port .... but i don't get anyting back 
without the timeout
uploaded 0.0.3 

can login, select a mailbox, get length? and pick
It's at the bottom of the page as a file attachment
Carl
19-Jan-2010
[1681]
BTW, nice use of Deki wiki.
Graham
19-Jan-2010
[1682x2]
It looks pretty but is slower than docbase :)
and there's no REBOL formatting .. so I use ruby or whatever ...
Carl
19-Jan-2010
[1684]
Runs really fast here. Where's the server?
Graham
19-Jan-2010
[1685x4]
I think EC2
It was a free hosting offer I picked up a couple of years ago ...
That is Mindtouch were offering free wikis to people limited to 200Mb 
I think
Of course what I really like about it is that there is a REST based 
API that I can use with REBOL.
Pekr
19-Jan-2010
[1689]
Carl - guys found out, that we have just one shared buffer - why? 
You have to read everything out during read phase, or you can get 
corrupted data ....
Graham
19-Jan-2010
[1690]
pekr, what protocols are full duplex?
Pekr
19-Jan-2010
[1691]
none ... but wasn't it you, after all, who just wondered, why the 
in-out buffer is shared?
Graham
19-Jan-2010
[1692]
No .. I just pointed it out.