Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Ansi -iso > Internet access...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 182 of 211
Post > Topic >>

Internet access example

by scott moore <nospam@[EMAIL PROTECTED] > May 23, 2006 at 05:25 PM

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




 6 Posts in Topic:
Internet access example
scott moore <nospam@[E  2006-05-23 17:25:50 
Re: Internet access example
"Pieter van Engen&qu  2006-09-10 14:18:38 
Re: Internet access example
Marco van de Voort <ma  2006-09-10 12:41:39 
Re: Internet access example
CBFalconer <cbfalconer  2006-09-10 09:48:00 
Re: Internet access example
scott moore <nospam@[E  2006-09-11 23:31:49 
Re: Internet access example
scott moore <nospam@[E  2006-09-11 23:09:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 14:14:13 CDT 2008.