1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
<html>
<head>
<title>~/src/firstworks/rudiments-0.31/include/rudiments/inetclientsocket.h.html</title>
<meta name="Generator" content="Vim/7.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000">
<pre>
<font color="#0000ff">// Copyright (c) 2002 David Muse</font>
<font color="#0000ff">// See the COPYING file for more information.</font>
<font color="#a020f0">#ifndef RUDIMENTS_INETCLIENTSOCKET_H</font>
<font color="#a020f0">#define RUDIMENTS_INETCLIENTSOCKET_H</font>
<font color="#a020f0">#include </font><font color="#ff00ff"><rudiments/private/inetclientsocketincludes.h></font>
<font color="#0000ff">// The inetclientsocket class allows you to write programs that can talk to</font>
<font color="#0000ff">// other programs across a network over TCP stream sockets.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// The inetclientsocket class provides methods for connecting to servers.</font>
<font color="#0000ff">// Its ultimate parent class: filedescriptor provides methods for reading and </font>
<font color="#0000ff">// writing data and closing connections.</font>
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
<font color="#2e8b57"><b>namespace</b></font> rudiments {
<font color="#a020f0">#endif</font>
<font color="#2e8b57"><b>class</b></font> inetclientsocketprivate;
<font color="#2e8b57"><b>class</b></font> inetclientsocket : <font color="#a52a2a"><b>public</b></font> clientsocket, <font color="#a52a2a"><b>private</b></font> inetsocketutil {
<font color="#a52a2a"><b>public</b></font>:
inetclientsocket();
inetclientsocket(<font color="#2e8b57"><b>const</b></font> inetclientsocket &i);
inetclientsocket &<font color="#a52a2a"><b>operator</b></font>=(<font color="#2e8b57"><b>const</b></font> inetclientsocket &i);
<font color="#2e8b57"><b>virtual</b></font> ~inetclientsocket();
<font color="#2e8b57"><b>int</b></font> connect(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *host,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>short</b></font> port,
<font color="#2e8b57"><b>long</b></font> timeoutsec,
<font color="#2e8b57"><b>long</b></font> timeoutusec,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>long</b></font> retrywait,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>long</b></font> retrycount);
<font color="#0000ff">// Convenience method that calls the initialize() and</font>
<font color="#0000ff">// connect() methods defined below.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Returns RESULT_SUCCESS on success and RESULT_ERROR</font>
<font color="#0000ff">// on failure.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// See connect() below for a note about use in</font>
<font color="#0000ff">// multithreaded applications.</font>
<font color="#0000ff">// These methods are split up in case you need to use them</font>
<font color="#0000ff">// seperately.</font>
<font color="#2e8b57"><b>void</b></font> initialize(constnamevaluepairs *cd);
<font color="#0000ff">// Queries constnamevaluepairs "cd" for "host", "port",</font>
<font color="#0000ff">// "timeoutsec", "timeoutusec", "retrywait" and</font>
<font color="#0000ff">// "retrycount". Initializes the class to use the</font>
<font color="#0000ff">// result when connect() is called.</font>
<font color="#2e8b57"><b>void</b></font> initialize(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *host,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>short</b></font> port,
<font color="#2e8b57"><b>long</b></font> timeoutsec,
<font color="#2e8b57"><b>long</b></font> timeoutusec,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>long</b></font> retrywait,
<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>long</b></font> retrycount);
<font color="#0000ff">// Initializes the class to use "host", "port",</font>
<font color="#0000ff">// "timeoutsec", "timeoutusec", "retrywait" and</font>
<font color="#0000ff">// "retrycount" when connect() is called.</font>
<font color="#2e8b57"><b>int</b></font> connect();
<font color="#0000ff">// Attempts to connect to the "host" and "port" set</font>
<font color="#0000ff">// earlier. If the connection fails, it will retry</font>
<font color="#0000ff">// "retrycount" times, waiting "retrywait" seconds</font>
<font color="#0000ff">// between retrycount. If "host" resolves to multiple</font>
<font color="#0000ff">// addresses, each address will be tried "retrycount"</font>
<font color="#0000ff">// times.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Setting "retrycount" to 0 will cause it to try to </font>
<font color="#0000ff">// connect indefinitely. Setting "retrywait" to 0</font>
<font color="#0000ff">// will cause it to try to connect over and over</font>
<font color="#0000ff">// as fast as possible (not recommended).</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Each attempt to connect will wait "timeoutsec"</font>
<font color="#0000ff">// seconds and "timeoutusec" microseconds for the</font>
<font color="#0000ff">// connect to succeed. Specifying -1 for either</font>
<font color="#0000ff">// parameter will cause the attempt to wait until the</font>
<font color="#0000ff">// underlying protocol times out which may be up to 2</font>
<font color="#0000ff">// minutes.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Returns RESULT_SUCCESS on success and RESULT_ERROR</font>
<font color="#0000ff">// on failure.</font>
<font color="#0000ff">//</font>
<font color="#0000ff">// Note that if your system does not support</font>
<font color="#0000ff">// getaddrinfo() then connect() uses the hostentry and</font>
<font color="#0000ff">// protocolentry classes. If you are using this method</font>
<font color="#0000ff">// in a multithreaded application, you may need to</font>
<font color="#0000ff">// supply those classes with mutexes. See hostentry.h</font>
<font color="#0000ff">// and protocolentry.h for more detail.</font>
<font color="#a020f0"> #include </font><font color="#ff00ff"><rudiments/private/inetclientsocket.h></font>
};
<font color="#a020f0">#ifdef RUDIMENTS_NAMESPACE</font>
}
<font color="#a020f0">#endif</font>
<font color="#a020f0">#endif</font>
</pre>
</body>
</html>
|