Annotation of libwww/Library/src/HTSocket.c, revision 2.30.2.2

2.1       frystyk     1: /*                                                                  HTSocket.c
2.29      frystyk     2: **     LOAD A SOCKET
2.1       frystyk     3: **
                      4: **     (c) COPYRIGHT MIT 1995.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
2.30.2.2! eric        6: **     @(#) $Id: HTSocket.c,v 2.30.2.1 1996/10/29 21:27:17 eric Exp $
2.1       frystyk     7: **
                      8: **
                      9: ** HISTORY:
2.29      frystyk    10: **     6 June 95  HFN  Written
2.1       frystyk    11: */
                     12: 
                     13: /* Library Include files */
2.25      frystyk    14: #include "sysdep.h"
2.30      frystyk    15: #include "WWWUtil.h"
                     16: #include "WWWCore.h"
                     17: #include "WWWTrans.h"
2.8       frystyk    18: #include "HTNetMan.h"
2.1       frystyk    19: #include "HTSocket.h"                                   /* Implemented here */
                     20: 
                     21: struct _HTStream {
2.25      frystyk    22:     const HTStreamClass *      isa;
2.1       frystyk    23: };
                     24: 
2.30      frystyk    25: struct _HTInputStream {
                     26:     const HTInputStreamClass * isa;
                     27: };
                     28: 
2.1       frystyk    29: /* ------------------------------------------------------------------------- */
2.27      frystyk    30: 
2.17      frystyk    31: /*     HTLoadSocket
                     32: **     ------------
                     33: **     Given an open socket, this routine loads what ever is on the socket
                     34: **
                     35: ** On entry,
                     36: **      request                This is the request structure
                     37: ** On Exit
                     38: **     returns         HT_ERROR        Error has occured in call back
                     39: **                     HT_OK           Call back was OK
                     40: */
2.30.2.2! eric       41: PRIVATE int SocketEvent (SOCKET soc, void * pVoid, HTEventType type);
2.30.2.1  eric       42: 
                     43: PUBLIC int HTLoadSocket (SOCKET soc, HTRequest * request)
2.17      frystyk    44: {
2.30      frystyk    45:     HTNet * net = HTRequest_net(request);
2.30.2.1  eric       46:     if (soc==INVSOC) {
                     47:        if (PROT_TRACE) HTTrace("Load Socket. invalid socket\n");
2.30      frystyk    48:        return HT_ERROR;
                     49:     }
2.30.2.1  eric       50:     if (PROT_TRACE) HTTrace("Load Socket. Loading socket %d\n",soc);
                     51: 
                     52:     /* 
                     53:     ** Create the stream pipe FROM the channel to the application.
                     54:     ** The target for the input stream pipe is set up using the
                     55:     ** stream stack.
                     56:     */
                     57:     {
                     58:        net->readStream = HTRequest_outputStream(request);
                     59:        if (!net->readStream) net->readStream = HTErrorStream();
                     60:        HTRequest_setOutputConnected(request, YES);
                     61:     }
                     62:     HTNet_setEventCallback(net, SocketEvent);
                     63:     HTNet_setEventParam(net, net);  /* callbacks get http* */
                     64: 
                     65:     return SocketEvent(soc, net, HTEvent_NONE);                /* get it started - ops is ignored */
                     66: }
                     67: 
2.30.2.2! eric       68: PRIVATE int SocketEvent (SOCKET soc, void * pVoid, HTEventType type)
2.30.2.1  eric       69: {
                     70:     HTNet * net = (HTNet *)pVoid;
                     71:     if (type == HTEvent_CLOSE) {                             /* Interrupted */
2.30      frystyk    72:        HTNet_delete(net, HT_INTERRUPTED);
2.17      frystyk    73:        return HT_OK;
                     74:     }
                     75: 
                     76:     /* In this load function we only have one state: READ */
                     77:     {
2.30.2.1  eric       78:        int status = HTHost_read(net->host);
2.30      frystyk    79:        if (PROT_TRACE) HTTrace("Load Socket. Read returns %d\n", status);
2.17      frystyk    80:     }
                     81:     return HT_OK;
                     82: }
2.27      frystyk    83: 

Webmaster