Re: Problems with webutils--solved, I think.
- Posted by gertie at ad-tek.net Aug 02, 2001
- 462 views
On 1 Aug 2001, at 22:58, Ted Fines wrote: > > Hi, all. > > I think just realized why it works on port 80 and not on 143. IMAP (143) > is a persistent connection, there wil only be a recognizable end to the > data stream after a logout command is issued. But http (80) is not > persistent, and after each reply, the connection is closed. Sound right? I looked for my pop3 file (port 110), and i use this to read the results of sending to the server: <working code> function ReadServer(object sock) sequence recievedline recievedline = "" while tcp4u_is_data_avail(sock) do sock_receive = tcp4u_receive(sock,1,1) if sock_connect[1] != TCP4U_SUCCESS then printf(1, "tcp4u_connect error '%s'\n", {tcp4u_error_string(sock_connect[tcp4u_ret])} ) exit end if if equal(sock_receive[2],{10}) then sock_receive[2] = "" end if if equal(sock_receive[2],{13}) then return recievedline else recievedline &= sock_receive[2] end if end while -- tcp4u_is_data_avail(sock_connect[2]) do return"" end function -- checkserver </working code> It's a little time consuming to run, but it's fast enough, and it took no time to write it. I use that same function in the SMTP section (port25), and almost the same code in the irc client (any port). Specifying one byte at a time is safest, it won't hang waiting for anything if the connection is broken, but it's also the slowest if everything is working perfectly. I do not close the port until after the logout in any of the cases: -- sign off properly SendToServer(sock_connect[2],"QUIT\r\n") -- listen for +OK for a little while -- close the port after +OK or timeout -- clean up tcp4u -- clean up this application -- end The gotcha in IMAP, as i understand RFC 1203, is that the client-server can change the command/handshake eol terminator string from crlf to whatever they want. I tried to look up the latest data at www.imap.org but somebody broke the internet here and i can't reach many websites since about midnight. Kat