Deutsch English
Alphabetical index
Array functions
CGI functions
Data types
Date functions
Debugging
Fulltext functions
Language elements
Numerical functions
Operators
Other functions
Ramtext functions
Selecting
Socket functions
  • closesock()
  • getsock()
  • opensock()
  • putsock()
  • server()
    Statistical functions
    Stream functions
    String functions
    System functions
    Table functions
    Text functions
    Home    Overview    Search    Impressum    Contact    Members
    Topic complex Socket functions
    Function closesock()
    Short Closes an existing connection
    Syntax closeSock(socket : INTEGER) : INTEGER
    Parameter socket : handle returned by openSock()
    Return
    See also:
    opensock() putsock() getsock()
    Description closeSock() shuts an open connection and frees all ressources used by it.

    Example 1: SMTP-Client

    A SMTP Client

    PROCEDURE send_str(s : INTEGER; l : STRING);
    VAR p : CHAR[1000];
      p[0]:=l+^M+^J; PutSock(s,p,length(l)+2)
      cgiwriteln('> '+l)
    ENDPROC
    PROCEDURE recv_str(s : INTEGER) : STRING;
    VAR p : CHAR[1000];
    VAR i : INTEGER;
    VAR res : STRING;
      nloop(i,GetSock(s,p,1000)-1,res:=res+p[i]);
      RETURN res
    ENDPROC
    
    PROCEDURE Main;
    VAR p : CHAR[1000];
    VAR i : INTEGER;
      cgiclosebuffer;
      cgiwriteln('content-type: text/plain');
      cgiwriteln('');
      IF i:=OpenSock('mail.tdb-engine.de:25') THEN
        cgiwriteln(recv_str(i));
        send_str(i,'HELO mail.tdb.de');
        cgiwriteln(recv_str(i));
        send_str(i,'MAIL FROM:test@tdb-engine.de');
        cgiwriteln(recv_str(i));
        send_str(i,'RCPT TO:test2@tdb-engine.de');
        cgiwriteln(recv_str(i));
        send_str(i,'DATA')
        cgiwriteln(recv_str(i));
        send_str(i,'Das ist ein kleiner Test.');
        send_str(i,'Und das ist die zweite Zeile');
        send_str(i,'.');
        cgiwriteln(recv_str(i));
        send_str(i,'QUIT');
        cgiwriteln(recv_str(i));
        CloseSock(i)
      ELSE
        cgiwriteln('done.')
      END
    ENDPROC
    


    User comments:
    Write a comment:
    Name
    EMail
    Subject
    Text (Switch mode)

    Choose between
    the normal and the
    advanced editor.
    The advanced editor
    runs in IE 5+ and
    Mozilla 1.4+ only
    SPAM-Protection Please enter tdbengine in this field.

    tdbengine chat
    irc.tdbengine.org
    #tdbengine

       Copyright © 2003-2004 tdb Software Service GmbH
       Alle rechte vorbehalten. / All rights reserved
       Last changed: 21.10.2004
    {Fehler für :execmacro{execmacro="sessionspy"}