Sorry for posting an example program, but I thought this was rather
poetic after the many complicated Internet access examples I have
seen. The Pascal used is IP Pascal.
{*********************************************************************
* *
* SIMPLE NETWORK ACCESS TEST PROGRAM *
* *
* Shows an example of network access via netlib. Accesses a mail *
* server, and orders a list of outstanding mail. This is then dumped *
* to the console. *
* *
*********************************************************************}
program nettst(input, output);
uses netlib,
strlib;
type bufstr = packed array 100 of char;
var mailin, mailout: text;
addr: integer;
buff: bufstr;
server: bufstr;
user: bufstr;
pass: bufstr;
msgnum: integer;
msgseq: integer;
procedure waitresp;
var t: bufstr;
begin
reads(mailin, t); { get response }
readln(mailin);
if t[1] <> '+' then begin
writeln('*** Error: protocol error');
halt
end
end;
begin
writeln('Mail server access test program');
writeln;
write('Please enter your email server: '); reads(input, server);
readln;
write('Please enter your username: '); reads(input, user); readln;
write('Please enter your password: '); reads(input, pass); readln;
addrnet(server, addr);
opennet(mailin, mailout, addr, 110);
waitresp;
writeln(mailout, 'user ', user);
waitresp;
writeln(mailout, 'pass ', pass);
waitresp;
writeln(mailout, 'list');
waitresp;
writeln('Message Sequence');
writeln('----------------');
while mailin^ <> '.' do begin
readln(mailin, msgnum, msgseq);
writeln(msgnum:7, ' ', msgseq:8);
end;
close(mailin);
end.
Example run:
C:\PASCOMP\windows>nettst
Mail server access test program
Please enter your email server: mail.server.net
Please enter your username: scott.moore
Please enter your password: mypass
Message Sequence
----------------
1 1603
2 7862
C:\PASCOMP\windows>
The program is simple because it opens and links an internet
server up as a pair of standard Pascal files, one for input,
and one for output.
Scott Moore


|