[Contents] [Index] [Help] [Browse <] [Browse >]


amarquee.library/QNewServerSession           amarquee.library/QNewServerSession

   NAME
    QNewServerSession - Link to the socket provided to your program
                        by inetd when you have been launched as
                        a server daemon by your TCP stack's inetd. (V50)

   SYNOPSIS
    #include 

    struct QSession * QNewServerSession(char * hostnames, char * prognames, struct TagItem *taglist)
    struct QSession * QNewServerSessionTags(char * hostnames, char * prognames, ULONG Tag1, ...)

   FUNCTION
    This function allows you to create "inetd style" daemon programs 
    that use amarquee.library to communicate with other amarquee 
    programs.  This function should be called only once, per 
    execution, near the beginning of your program.  It will 
    return a QSession that you can use to communicate with the 
    amarquee client that connected to your computer.  Your app will 
    receive an initial message containing the identity of the 
    connecting program (e.g. "/computer.name/progName") in the qm_Path
    field.  After that communication takes place in the same 
    way used by connections made via QNewHostSession.

   NOTE
    This function will NOT work with the Inet225 version of
    amarqueed.library.  This is because under Inet225 the inherited
    socket info is passed via main's() argc and argv parameters, which
    this call does not have access to.
    Email me if you need this call to work under Inet225; if there
    is demand I will try and work out a solution.
    
    This function will return NULL if your program was not started
    by inetd, or if the connecting program does not meet the 
    criteria specified in the arguments to this function.
    
    Once a connected QSession has been disconnected, it can no longer
    be used for anything and should be freed.  You cannot receive a
    second connection with this function (a second connection will
    launch a second instance of your program instead).
    
    Don't forget to call QFreeSession'd on all allocated 
    QSessions before you close amarquee.library!
    
    This function requires v38+ of amarquee.library.
    
    For an example of how to use this function, see the file
    AMarqueeServer.c in the examples directory.
    
   INPUTS
    hostnames - A regular expression determining which hosts are
                allowed to connect to this QSession.  For example,
                "#?" would allow any host to connect, or "#?.edu"
                would allow only hosts from schools to connect.
    prognames - A regular expression determining which program names
                are allowed to connect to this QSession.  The connecting
                program's name is specified by the connecting program
                when it calls QNewSession.  
    taglist   - A pointer to a tag list. For usable tags see .
                You can set this to NULL if you don't want to use any tags.

   TAGS
   Same tags as QNewSession().

   RESULTS
    On success, returns a pointer to a QSession struct that may be
    used with the other functions in this API.  The QSession struct
    also contains a pointer to an exec.library MsgPort that your program
    should Wait() on and GetMsg() from to receive QMessages from the
    TCP thread.  Returns NULL if a listening port could not be established
    (likely because another program was using the port you wanted!).

   EXAMPLE
    struct QSession * s;
    
    if (s = QNewServerSession("#?", "#?"))
       printf("Got the session from InetD.  Ready to go!\n");
    else
       printf("Couldn't get session from InetD.\n");
   
   NOTE
    This function was modified in amarquee.library v.50. The v.49 version had the
    same function but without the last argument, struct TagItem *taglist. I.e tags
    could not be used. Use the AMarquee49 pragmas and protos if your program have
    to work with amarquee.library v.49, though it's not recommended.

   AREXX NOTES
    For ARexx, the return value of this method is a string representation 
    of the pointer to the session struct.  If the returned value is equal 
    to zero, then the call failed.  Otherwise, use the return value as a 
    handle to pass to other amarquee.library functions.

    Note that instead of calling Wait() and GetMsg(), you will want
    to use amarquee.library's GetNextQMessage function to receive
    incoming QMessages.

    Note that in order for this command to be useful, your ARexx script
    must have been launched by inetd.  I'm not sure how that is done...
    
   AREXX EXAMPLE
    session = QNewServerSession('#?', '#?')
    if (session > 0) then say "Call was successful!"
                     else say "Call failed!"

   SEE ALSO
    QNewSession, QNewSessionAsync, QNewHostSession, QFreeSession


Converted on 24 Mar 2002 with RexxDoesAmigaGuide2HTML 2.1e(private) by Michael Ranner.