Annotation of libwww/Library/src/HTTCP.html, revision 2.45
2.17 frystyk 1: <HTML>
2: <HEAD>
2.41 frystyk 3: <!-- Changed by: Henrik Frystyk Nielsen, 1-Jul-1996 -->
2.42 frystyk 4: <TITLE>W3C Sample Code Library libwww Socket Open and Close</TITLE>
2.17 frystyk 5: </HEAD>
2.2 timbl 6: <BODY>
2.39 frystyk 7: <H1>
2.41 frystyk 8: Socket Open and Close
2.39 frystyk 9: </H1>
2.17 frystyk 10: <PRE>
11: /*
2.25 frystyk 12: ** (c) COPYRIGHT MIT 1995.
2.17 frystyk 13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
2.39 frystyk 16: <P>
17: The Socket Open and Close methods knows how to establish a BSD socket TCP
18: connection and is part of the <A HREF="WWWTrans.html">Transport interface</A>.
19: <P>
20: This module is implemented by <A HREF="HTTCP.c">HTTCP.c</A>, and it is a
2.43 frystyk 21: part of the <A HREF="http://www.w3.org/Library/">W3C Sample Code
2.39 frystyk 22: Library</A>.
2.8 frystyk 23: <PRE>
24: #ifndef HTTCP_H
2.2 timbl 25: #define HTTCP_H
2.30 frystyk 26: #include "HTReq.h"
27: #include "HTNet.h"
2.45 ! vbancrof 28:
! 29: #ifdef __cplusplus
! 30: extern "C" {
! 31: #endif
2.8 frystyk 32: </PRE>
2.39 frystyk 33: <H2>
34: Active Connection Establishment
35: </H2>
36: <P>
37: This makes an active <CODE>connect</CODE> to the specified host. An
38: <A HREF="HTNet.html">HTNet Object</A> is parsed in order to handle errors
39: and other stuff. The default port might be overwritten by any port indication
2.43 frystyk 40: in the <A HREF="http://www.w3.org/Addressing/">URL</A> specified
2.39 frystyk 41: as <CODE><host>:<port></CODE> If it is a <I>multihomed host </I>(a
42: host having multiple IP-addresses with the same host name) then
43: <CODE>HTDoConnect()</CODE> measures the time it takes to connect and updates
44: the calculated weights in the <A HREF="HTDNS.html">DNS object</A>.
2.8 frystyk 45: <PRE>
2.44 frystyk 46: extern int HTDoConnect (HTNet * net);
2.8 frystyk 47: </PRE>
2.39 frystyk 48: <H2>
49: Passive Connection Establishment
50: </H2>
51: <P>
52: This function makes an <CODE>accept</CODE> on a port. The net must contain
2.41 frystyk 53: a valid socket to accept on. If accept is OK then we <I>duplicate</I> the
54: net object and assign the accepted socket to the newly created net object.
55: The original <A HREF="HTNet.html">Net object</A> will keep accepting connections
56: on the original socket, for example port 80 in the case of
57: <A HREF="HTTP.html">HTTP</A>. The newly created Net object will be freed
58: when the <A HREF="HTProt.html">protocol module</A> has finished. If the
59: <I>accepted</I> net object pointer points to the net object itself, that
60: is - the same object all along - then we reuse the same Net obejct; closes
61: the original socket and replaces it wik the accepted one. This is a quick
62: way of accepting a single connection.
2.44 frystyk 63: <PRE>
64: extern int HTDoAccept (HTNet * listen, HTNet * accept);
2.32 frystyk 65: </PRE>
2.39 frystyk 66: <H2>
67: Listen on a Socket
68: </H2>
69: <P>
2.44 frystyk 70: Listens on the specified port described in the Net
71: object. <CODE>backlog</CODE> is the number of connections that can be
72: queued on the socket - you can use <CODE>HT_BACKLOG</CODE> for a
73: platform dependent value (typically 5 on BSD and 32 on SVR4). Returns
74: <CODE>HT_ERROR</CODE> or <CODE>HT_OK</CODE>.
75: <PRE>
76: extern int HTDoListen (HTNet * net, HTNet * accept, int backlog);
2.8 frystyk 77: </PRE>
2.41 frystyk 78: <H2>
79: Closing a socket
80: </H2>
81: <P>
2.40 frystyk 82: Closes a socket
83: <PRE>
84: extern int HTDoClose (HTNet * net);
85: </PRE>
2.8 frystyk 86: <PRE>
2.45 ! vbancrof 87: #ifdef __cplusplus
! 88: }
! 89: #endif
! 90:
2.2 timbl 91: #endif /* HTTCP_H */
2.8 frystyk 92: </PRE>
2.39 frystyk 93: <P>
94: <HR>
2.38 frystyk 95: <ADDRESS>
2.45 ! vbancrof 96: @(#) $Id: HTTCP.html,v 2.44 1999/07/07 15:43:28 frystyk Exp $
2.38 frystyk 97: </ADDRESS>
2.39 frystyk 98: </BODY></HTML>
Webmaster