POP3 or IMAP

Dar Scott dsc at swcp.com
Tue Feb 18 14:20:01 EST 2003


On Sunday, February 16, 2003, at 12:20 PM, Mike Doub wrote:

> Has anyone developed any code to get mail via POP3?   I seem to be 
> having
> problems reopening a socket.

Here are some comments that address this as a generic client-to-server 
TCP problem.

Often servers will allow multiple connections, but I would not be 
surprised if a server declined multiple connections from the same 
client computer or declined immediate reconnection or declined a 
connection based on a security trigger.  So, as Sarah said, make sure 
you close your connection.

Not closing a connection can cause confusion in callbacks; you might be 
responding to the wrong connection.

Handle callbacks (except maybe timeout, depending on your style).

It is easy to add a connectionID to the socketID, so you may want to do 
this even if you are not (intentionally) making multiple connections.  
You can use this as a double check in callbacks and as extra debug 
information.  (One way is to use a script local variable for all 
socketID references and to tag on a serial number when you set the 
variable.)  I'm referring to the entire "10.20.0.1:123|POP300001" as 
the socket ID and "POP300001" as the connection ID in that example; I 
hope I'm not misusing Revolution nomenclature.

In debug logs I report the result as well as the sysError.  Those 
familiar with your platform might help you with the sysError values.  I 
also log the long time or milliseconds since the open (attempt).  This 
time can give a clue.  For example, a nine-second delay in the open 
error callback on Windows normally means the connection was refused.  
Log the socket closed and socket error callbacks.

If you close a connection and immediately open a connection, there 
might be some confusion on OS X; use a connectionID to sort out 
callbacks.

There are some platform differences.  A minor one is the delay should 
the target computer not exist or be unreachable.  This is about 21 
seconds on my XP, but 75 seconds on my OS X.  One difference more 
likely to cause confusion is related to callbacks.

For example, for Revolution 2.0, this was reported for an Alpha version:
> OS X and XP still have different callback behavior for TCP in some 
> cases...
>                                 OS X              XP
> Open Refused                socketClosed       socketError
> Open Timeout                socketClosed       socketError
> Local Close                 socketClosed       none

I believe the situation is similar with Revolution 1.1.1.

I don't believe this will change soon; scriptors should adapt.

Note that socketClosed is called instead of socketError on OS X.  Also, 
note that you can get a callback on a socket after you close it.

If you _want_ to have multiple connections, let us know.

I realize this is a general shotgun response.  The point of error and 
the error information can help us be more specific in responding.

Dar Scott













More information about the use-livecode mailing list