1. POPCheck v0.5
Greetings,
Below is a program which uses the winsock routines. It queries a POP3
server and checks if there are any messages. Then my program pops up a
dialog if there is such a message. Note that you need the winsock package
to run this program.
The dialog will look like this.
Cavaet: This assumes that your pop server formats its responses just like my
pop server. This is in theory true, as the protocol is stated in RFC1939,
but I make no guarantees.
Cavaet 2: you need to modify the POPserver, user, and password variables in
my program to your server.
Alan
-- begin code
without warning
include winsock.ew -- Does include Win32lib
-- begin GetSock.ew
-- in this file for simplicity for e-mailing purposes
global function GetSockLine(integer client)
sequence data
object temp
data = {}
temp = WsockReadData(client,1)
while temp[1] != 10 and temp[1] != 13 do
data = data & temp[1]
temp = WsockReadData(client,1)
end while
if length(data) = 0 then
data = GetSockLine(client)
end if
return data
end function
-- end getsock.ew
-- POP3 Server Check v0.5
-- Code modified from Greg Harris
-- March 21, 2000
-- This program checks if there are messages on
-- your POP3 server.
--include GetSock.ew
integer response, client
sequence Okay, ProgName, POPserver, user, password
object errorRtn, data
----- begin user modifiable constants -----
POPserver = "students.uiuc.edu"
user = ""
password = ""
----- end user modifiable constants -----
Okay = "Everything in Wsock32 Ok."
ProgName = "Wsclient.exw"
SocketTrace = 1 -- Play with 0 or 1
errorRtn = WsockInit()
if errorRtn != 0 then
Say("Error initializing Winsock.",ProgName)
abort(1)
end if
puts(1, "Opening socket..")
puts(1,"Trying to connect..\n")
client = WsockCallSocket(POPserver,110)
if client = SOCKET_ERROR then
puts(1, "Failed to connect!\n\n")
errorRtn = WsockRelease()
if errorRtn != 0 then
Say("Error releasing Winsock.",ProgName)
end if
abort(1)
else
puts(1, "Connected - Socket number is:" & sprintf("%d\n",client))
end if
errorRtn = WsockSendData(client,"user " & user & '\n')
data = GetSockLine(client)
errorRtn = WsockSendData(client,"pass " & password & '\n')
data = GetSockLine(client)
errorRtn = WsockSendData(client,"stat\n")
data = GetSockLine(client)
data = GetSockLine(client)
if sequence(data) then
Say(data,"Winsock Says!")
end if
puts(1, "Closing socket.\n")
WsockCloseSocket(client)
errorRtn = WsockRelease()
if errorRtn != 0 then
Say("Error releasing Winsock.",ProgName)
end if
Say(Okay,ProgName)
-- end code