I submitted it ot SF
http://sourceforge.net/tracker/index.php?func=detail&aid=726288&group_id=3152&atid=303152
but it is quite old already, i have newer version but did not submit it.
The idea is same just little improvements.
We use this proxy module for 1 year already in th eproduction, no
problems at all, it co-exists with normal http driver
in the same aolserver process, they both reuse same connection pool.

i am working on generic TCP server using new patch, hope to release it soon.

Basically new driver will look like this, just need to export socket
interface to Tcl, so i can read/write
to socket from scripts. All Ns_Conn fields are available and C API i
used same way as for HTTP connections.

typedef struct {
    char *server;
    char *initproc;
    char *dataproc;
    Ns_Driver *driver;
} TcpServer;


NS_EXPORT int Ns_ModuleInit(char *server, char *module) { TcpServer *serverPtr; Ns_DriverInitData init;

    serverPtr = ns_calloc(1,sizeof(TcpServer));
    serverPtr->server = server;
    serverPtr->initproc = Ns_ConfigGet(path,"initproc");
    serverPtr->heloproc = Ns_ConfigGet(path,"dataproc");

    init.version = NS_DRIVER_VERSION_1;
    init.name = "tcpserver";
    init.proc = TcpServerProc;
    init.opts = NS_DRIVER_RAW;
    init.arg = serverPtr;
    init.path = NULL;

    if(Ns_DriverInit(server, module, &init) != NS_OK) {
      Ns_Log(Error, "nstcpserver: driver init failed.");
      return NS_ERROR;
    }
    return NS_OK
}

static int
TcpServerProc(Ns_DriverCmd cmd, Ns_Sock *sock, struct iovec *bufs, int
nbufs)
{
    TcpServer *server = sock->driver->arg;

    switch(cmd) {
     case DriverStart:
         server->driver = sock->driver;
         if(server->initproc)
Ns_TclEval(0,server->server,server->initproc);
         return NS_OK;

     case DriverError:
         sleep(3);
         exit(0);
         break;

     case DriverProc:
         TcpServerThread(server,sock);
         return NS_FILTER_BREAK;

     case DriverRecv:
     case DriverSend:
     case DriverKeep:
     case DriverClose:
         break;
    }
    return NS_ERROR;
}

static void
TcpServerThread(TcpServer *server,Ns_Sock *sock)
{
    Ns_Conn *nsconn = Ns_GetConn();

    TclInterp *interp = Ns_GetConnInterp(nsconn);

     if(interp && server->dataproc)
Ns_TclEval(0,server->server,server->dataproc);

}


Andrew Piskorski wrote:
On Fri, May 28, 2004 at 12:58:36PM -0400, Vlad Seryakov wrote:


I have patch that convert aolserver into generic threaded server
platform. I had to write SMTP proxy server and it required just a
small patch to change default HTTP-aware behaiviour of server
thread. Now it supports generic drivers and uses same thread
pools/connection driver as for http communications.


That sounds quite useful.  Vlad, where is this patch available?  Dossy
or others, can it go into the standard AOLserver sources?

--
Andrew Piskorski <[EMAIL PROTECTED]>
http://www.piskorski.com/


-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

-- Vlad Seryakov 703 488-2173 office [EMAIL PROTECTED] http://www.crystalballinc.com/vlad/


-- AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to