?? htnet.h
字號:
)We have some small functions that tell whether there are registered requestsin the Net manager. There are tree queues: The active, thepending, and the persistent. The active queueis the set of requests that are actively sending or receiving data. Thepending is the requests that we have registered but which are waitingfor a free socket. The Persistent queue are requets that are waitingto use the same socket in order to save network resoures (if the serverunderstands persistent connections). Active Requests?Returns whether there are requests in the active queue or not*/extern BOOL HTNet_idle (void);/* Registered Requests?Returns whether there are requests registered in any of the lists or not*/extern BOOL HTNet_isEmpty (void);extern int HTNet_count (void);/*( List Pending Queue)Returns the list of pending requests that are waiting to become active. Returnslist of HTNet objects or NULL if error*/extern HTList *HTNet_pendingQueue (void);/*. Creation and Deletion Methods.The Net object is intended to live as long as the request is still active.In that regard it is very similar to the Request Object. However, the main difference is that a Net object represents a "thread"in the Library and a request may have multiple "threads" - an example isa FTP request which has a thread to handle the control connection and oneto handle the data connections.( Create a new Object)If we have more than HTMaxActive connections already then put this into thepending queue, else start the request by calling the call back functionregistered with this access method. Returns YES if OK, else NO*/extern BOOL HTNet_newClient (HTRequest * request);/*You can create a new HTNet object as a new request to be handled. If we havemore than HTMaxActive connections already then return NO. Returns YES ifOK, else NO*/extern BOOL HTNet_newServer (HTRequest * request);/*And you can create a plain new HTNet object using the following method:*/extern HTNet * HTNet_new (HTHost * host);/*( Duplicate an existing Object)Creates a new HTNet object as a duplicate of the same request. Returns YESif OK, else NO.*/extern HTNet * HTNet_dup (HTNet * src);extern BOOL HTNet_deleteDup (HTNet * dup);/*( Launch a Net Object)Start a Net obejct by calling the protocol module.*/extern BOOL HTNet_start (HTNet * net);/*( Call a Net Event Handler)This functions lets the caller play event manager as it can calls any eventhandler with the event type and context passed to the function*/extern BOOL HTNet_execute (HTNet * net, HTEventType type);extern HTEvent * HTNet_event (HTNet * net);extern BOOL HTNet_setEventParam (HTNet * net, void * eventParam);extern void * HTNet_eventParam (HTNet * net);extern BOOL HTNet_setEventCallback(HTNet * net, HTEventCallback * cbf);extern HTEventCallback * HTNet_eventCallback(HTNet * net);/*( Delete an Object)Deletes the HTNet object from the list of active requests and calls anyregistered call back functions IF not the status is HT_IGNORE. This is usedif we have internal requests that the app doesn't know about. We also seeif we have pending requests that can be started up now when we have a socketfree. The filters are called in the reverse order of which they were registered(last one first);*/extern BOOL HTNet_delete (HTNet * me, int status);/*( Delete ALL HTNet Objects)Deletes all HTNet object that might either be active or pending We DO NOTcall the call back functions - A crude way of saying goodbye!*/extern BOOL HTNet_deleteAll (void);/*. Net Class Methods.( Make an Object Wait)Let a net object wait for a persistent socket. It will be launched from theHTNet_delete() function when the socket gets free.*/extern BOOL HTNet_wait (HTNet *net);/*( Priority Management)Each HTNet object is created with a priority which it inherits from theRequest manager. However, in some stuations it isuseful to be to change the current priority after the request has been started.These two functions allow you to do this. The effect will show up the firsttime (which might be imidiately) the socket blocks and control returns tothe event loop. Also have a look at how you can do this before the requestis issued in the request manager.*/extern HTPriority HTNet_priority (HTNet * net);extern BOOL HTNet_setPriority (HTNet * net, HTPriority priority);/*( Persistent Connections)You can set a Net object to handle persistent connections for example usingHTTP, NNTP, or FTP. You can control whether a Net object supports persistentconnections or not using this function.*/extern BOOL HTNet_persistent (HTNet * net);/*You can set or disable a Net object supporting persistent connections usingthis function:*/extern BOOL HTNet_setPersistent (HTNet * net, BOOL persistent, HTTransportMode mode);/*( Kill one or more Requests) Kill this request and all requests in the PipelineWhen pipelining, it is not possible to kill a single request as we then loosetrack of where we are in the pipe. It is therefore necessary to kill thewhole pipeline.*/extern BOOL HTNet_killPipe (HTNet * net);/* Kill a single RequestThis is not often used anymore, consider using the pipeline version above.Kill the request by calling the call back function with a request for closingthe connection. Does not remove the object. This is done by HTNet_delete()function which is called by the load routine. Returns OK if success, NO onerror.*/extern BOOL HTNet_kill (HTNet * me);/* Kill ALL RequestsKills all registered (active as well as pending) requests by callingthe call back function with a request for closing the connection. We do notremove the HTNet object as it is done by HTNet_delete(). Returns OK if success,NO on error*/extern BOOL HTNet_killAll (void);/*( Create Input and Output Streams)You create the input stream and bind it to the channel using the followingmethods. Please read the description in theHTIOStream module on the parameterstarget, param, and mode. Both methods return YESif OK, else NO.*/#if 0extern HTInputStream * HTNet_getInput (HTNet * net, HTStream * target, void * param, int mode);#endifextern HTOutputStream * HTNet_getOutput (HTNet * me, void * param, int mode);/*( Net Context Descriptor)Just like the requestobject, a net object can be assigned a context which keeps track of contextdependent information. The Library does not use this information nor doesit depend on it but it allows the application to customize a net object tospecific uses.*/extern BOOL HTNet_setContext (HTNet * net, void * context);extern void * HTNet_context (HTNet * net);/*( Socket Descriptor)*/extern BOOL HTNet_setSocket (HTNet * net, SOCKET sockfd);extern SOCKET HTNet_socket (HTNet * net);/*( Preemptive or Non-preemptive Access)A access scheme is defined with a default for using either preemptive (blockingI/O) or non-premitve (non-blocking I/O). This is basically a result of theimplementation of the protocol module itself. However, if non-blocking I/Ois the default then some times it is nice to be able to set the mode to blockinginstead. For example when loading the first document (the home page) thenblocking can be used instead of non-blocking.*/extern BOOL HTNet_preemptive (HTNet * net);/*( The Request Object)The Request object is normally set up automaticallybut can be changed at a later time.*/extern BOOL HTNet_setRequest (HTNet * net, HTRequest * request);extern HTRequest * HTNet_request (HTNet * net);/*( The Protocol Object)*/extern BOOL HTNet_setProtocol (HTNet * net, HTProtocol * protocol);extern HTProtocol * HTNet_protocol (HTNet * net);/*( The Transport Object)The transport object is normally set up automaticallybut can be changed at a later time.*/extern BOOL HTNet_setTransport (HTNet * net, HTTransport * tp);extern HTTransport * HTNet_transport (HTNet * net);/*( The Channel Object)*/extern BOOL HTNet_setChannel (HTNet * net, HTChannel * channel);extern HTChannel * HTNet_channel (HTNet * net);/*( The Host Object)*/extern BOOL HTNet_setHost (HTNet * net, HTHost * host);extern HTHost * HTNet_host (HTNet * net);/*( The DNS Object)The DNS object keeps track of the DNS entries that we have already checkedout.*/extern BOOL HTNet_setDns (HTNet * net, HTdns * dns);extern HTdns * HTNet_dns (HTNet * net);/*( Target for Input Read Stream)*/extern HTStream * HTNet_readStream(HTNet * net);extern BOOL HTNet_setReadStream (HTNet * net, HTStream * stream);/*( Should we count Raw bytes?)This functions can be used to determine whether bytes count should be managedat the low level read stream or at a higher level. If the data transfer equalsthe lifetime of a single document like for example in FTP or HTTP/1.0 thenthis may be a reasonable thing to do.*/extern BOOL HTNet_setRawBytesCount (HTNet * net, BOOL mode);extern BOOL HTNet_rawBytesCount (HTNet * net);/**/#endif /* HTNET_H *//* @(#) $Id: HTNet.html,v 2.57 2000/07/04 15:18:51 kahan Exp $*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -