<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
<channel>
  <title>The C++ Community</title>
  <link>http://community.livejournal.com/cpp/</link>
  <description>The C++ Community - LiveJournal.com</description>
  <lastBuildDate>Sat, 19 Jul 2008 19:43:57 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>cpp</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>http://p-userpic.livejournal.com/975485/412096</url>
    <title>The C++ Community</title>
    <link>http://community.livejournal.com/cpp/</link>
    <width>100</width>
    <height>74</height>
  </image>

<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/318916.html</guid>
  <pubDate>Sat, 19 Jul 2008 19:43:57 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/318916.html</link>
  <description>I&apos;ve been using DevC++ for a long time, but I&apos;m now moving on and looking for a cross-platform IDE and/or compiler.  Any suggestions?</description>
  <comments>http://community.livejournal.com/cpp/318916.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>thelosthoplite</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/318626.html</guid>
  <pubDate>Wed, 16 Jul 2008 23:57:14 GMT</pubDate>
  <title>Very interesting situation for realloc</title>
  <link>http://community.livejournal.com/cpp/318626.html</link>
  <description>I have pointer to small struct. For example:&lt;br /&gt;&lt;br /&gt;struct a&lt;br /&gt;{&lt;br /&gt; unsignred long number;&lt;br /&gt; char *name;&lt;br /&gt;} *pa;&lt;br /&gt;&lt;br /&gt;where *pa allocated with realloc:&lt;br /&gt;pa = realloc(pa, sizeof(a)*Num_a);&lt;br /&gt;&lt;br /&gt;and Num_a can be very great and always increasing. And i have interesting situation: for any realloc call system allocate block of memory (above than current block because block greater than current can be only above) and copy old block. then system freeing old block. For new realloc call memory which lower current block is too small for allocate for new size. And system allocate block above. All works while allocated memory less than free memory/2 and address of allocated block below memory/2. When it&apos;s condition is false (size of need memory greater than memory/2) i have exception in realloc or API functions. And have enough memory below current allocation.&lt;br /&gt;&lt;br /&gt;What you can advise? linked list will be very slow for big number of records :(</description>
  <comments>http://community.livejournal.com/cpp/318626.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>pagankz</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/318231.html</guid>
  <pubDate>Wed, 16 Jul 2008 22:38:36 GMT</pubDate>
  <title>DNS Bug</title>
  <link>http://community.livejournal.com/cpp/318231.html</link>
  <description>This is not really about C/C++, but it is a lesson in the ubiquity of bugs, so if you or your company uses DNS you probably want to make sure this is known.  And if you are a hacker you&apos;ll probably want to following this -- but then you may already know.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.0xdeadbeef.com/weblog/?p=407&quot;&gt;A flaw has apparently been found in the DNS system that most of the Internet uses. (Secure DNS doesn’t have this problem, but it’s used by very few people.) It’s not just a problem with a particular implementation of DNS. It’s a problem that every single implementation apparently suffers from. It’s very very scary and just about every vendor has pushed out a fix ahead of the release of the details of the problem. I’ve spent some of today updating every single machine that I have have access to. You should do the same. &lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I&apos;ve had bugs that existed undetected in code for more than two years, and then someone did something different.</description>
  <comments>http://community.livejournal.com/cpp/318231.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>redslime</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/317977.html</guid>
  <pubDate>Fri, 27 Jun 2008 14:16:39 GMT</pubDate>
  <title>Templated full template specialisations</title>
  <link>http://community.livejournal.com/cpp/317977.html</link>
  <description>Ok, I&apos;m not sure this is possible, so please tell me if it isn&apos;t, but I want to write a full template specialisation that is itself dependent on a templated type.  Can it be done?&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;So this is class elmnt_Metropolis:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;font color=&quot;#990000&quot;&gt;		template&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;typename&lt;/font&gt; _Likelihood&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;=&lt;/font&gt;&lt;/b&gt;Likelihood&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt;double&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt; double&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt; double&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt; &amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;

		class&lt;/font&gt; elmnt_Metropolis&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt; :&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt; public&lt;/font&gt; Element&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;_Likelihood&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt;
		{&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;
			public&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;:&lt;/font&gt;&lt;/b&gt;

			array&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt;double&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/b&gt;	jump_spec&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;;&lt;/font&gt;&lt;/b&gt;

			random_num_gen&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;	*&lt;/font&gt;&lt;/b&gt;rng_jump&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;;&lt;/font&gt;&lt;/b&gt;
			random_num_gen&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;	*&lt;/font&gt;&lt;/b&gt;rng_accept&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;;&lt;/font&gt;&lt;/b&gt;

			elmnt_Metropolis&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;() :&lt;/font&gt;&lt;/b&gt; rng_jump&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;(&lt;/font&gt;&lt;/b&gt;NULL&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;),&lt;/font&gt;&lt;/b&gt; rng_accept&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;(&lt;/font&gt;&lt;/b&gt;NULL&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;) {}&lt;/font&gt;&lt;/b&gt;
			elmnt_Metropolis&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;(&lt;/font&gt;&lt;/b&gt; random_num_gen&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt; *&lt;/font&gt;&lt;/b&gt;one&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt; random_num_gen&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt; *&lt;/font&gt;&lt;/b&gt;two&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt; array&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt;double&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt; &amp;amp;&lt;/font&gt;&lt;/b&gt;_jump_spec&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt; );&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;

			virtual&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt; ~&lt;/font&gt;&lt;/b&gt;elmnt_Metropolis&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;(){}&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;

			virtual&lt;/font&gt;&lt;font color=&quot;#FF6633&quot;&gt;	bool&lt;/font&gt;	jump&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;();&lt;/font&gt;&lt;/b&gt;&lt;i&gt;&lt;font color=&quot;#999999&quot;&gt;	//The function that makes the element think about moving (returns true if it did, false if it didn&apos;t)

&lt;/font&gt;&lt;/i&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;		};&lt;/font&gt;&lt;/b&gt;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;which has a member function called jump.  I want to overide this for a class LogLikelihood which is identical to Likelihood (three template parameters, shown in the default argument to elmnt_Metropolis).&lt;br /&gt;&lt;br /&gt;I have done this thinking it might do what I want:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;font color=&quot;#990000&quot;&gt;		template&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;
			template&lt;/font&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt;typename&lt;/font&gt; _param_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt; typename&lt;/font&gt; _value_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#990000&quot;&gt; typename&lt;/font&gt; _arg_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt;&lt;/font&gt;&lt;/b&gt;&lt;font color=&quot;#FF6633&quot;&gt;

		bool&lt;/font&gt;	elmnt_Metropolis&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt; LogLikelihood&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;lt;&lt;/font&gt;&lt;/b&gt;_param_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt; _value_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;,&lt;/font&gt;&lt;/b&gt; _arg_type&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;&amp;gt; &amp;gt;::&lt;/font&gt;&lt;/b&gt;jump&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;()
		{&lt;/font&gt;&lt;/b&gt;&lt;i&gt;&lt;font color=&quot;#999999&quot;&gt;

			//...
&lt;/font&gt;&lt;/i&gt;&lt;b&gt;&lt;font color=&quot;#663300&quot;&gt;		}&lt;/font&gt;&lt;/b&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and got this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;../../../LALpp/mcmctl/elmnt_Metropolis.hpp:101: error: no member function &apos;jump&apos; declared in &apos;LALpp::mcmctl::elmnt_Metropolis&amp;lt;LALpp::mcmctl::LogLikelihood&amp;lt;_param_type, _value_type, _arg_type&amp;gt; &amp;gt;&apos;
../../../LALpp/mcmctl/elmnt_Metropolis.hpp:101: error: invalid function declaration&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Can I do this?  What am I doing wrong if I can?  And even if it can&apos;t be done, what does that error message &lt;i&gt;mean&lt;/i&gt; (beyond the glaringly obvious)?  Thanks in advance.&lt;br /&gt;&lt;br /&gt;</description>
  <comments>http://community.livejournal.com/cpp/317977.html</comments>
  <lj:music>Infected Mushroom - Elation Station</lj:music>
  <lj:security>public</lj:security>
  <lj:poster>synergetic</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/317863.html</guid>
  <pubDate>Mon, 23 Jun 2008 13:29:37 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/317863.html</link>
  <description>Looking for class for evaluating expressions (like 8+sin(3)*3*(2+2)) and would be nice if c++ builder can compile it.</description>
  <comments>http://community.livejournal.com/cpp/317863.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lastcomm</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/317523.html</guid>
  <pubDate>Sun, 22 Jun 2008 13:10:35 GMT</pubDate>
  <title>Function template to read both int and string</title>
  <link>http://community.livejournal.com/cpp/317523.html</link>
  <description>A question from a c++ newbie.&lt;br /&gt;I&apos;m implementing a function template that reads from an input stream. The type of input is not known and can be int, char, string, etc. I&apos;m stuck at the point where the input is actually read, that is:&lt;br /&gt;in &amp;gt;&amp;gt; temp;&lt;br /&gt;because I can read almost any type by using the &amp;gt;&amp;gt; operator except a string where I have to use getline(). &lt;br /&gt;Is there a way around this in one single function template without overloading it specifically for the string type?</description>
  <comments>http://community.livejournal.com/cpp/317523.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>ryzhyk_pyzhyk</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/317202.html</guid>
  <pubDate>Thu, 19 Jun 2008 05:26:40 GMT</pubDate>
  <title>Classes embedded in Classes</title>
  <link>http://community.livejournal.com/cpp/317202.html</link>
  <description>My intro computer science class went over classes fairly quick, and the teacher never as much as mentioned classes within classes. Now I&apos;m in the next level class and the second lab requires a class to use another private class as a linked list with only access to the head and tail. My question about this is, what&apos;s the notation I&apos;m supposed to use? Class Counter220 is a header, and i&apos;m sure that I wouldn&apos;t be able to create &quot;local_node *p;&quot; in the .cpp file for the header so what would the correct form be? Counter220* local_node::p = Null? And then access it through local_node::p-&amp;gt;count?&lt;br /&gt;&lt;br /&gt;Sorry to be such a bother, but I don&apos;t have access to the course compiler until monday so i&apos;m just writing out the rough draft.&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;
#ifndef COUNTER220_H_
#define COUNTER220_H_

#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cstring&gt;
using namespace std;

class Counter220{

protected:
        Counter220();

public:
        virtual ~Counter220();
        int increment(char *item_name);
        int decrement(char *item_name);
        int count(char *item_name);
        static Counter220* Instance();

private:
        class local_node{
        public:
                        local_node      *next;
                        char            *name;
                        int             count;
                };

        local_node *head;
        local_node *tail;
};
#endif /*COUNTER220_H_*/

&lt;/html&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;</description>
  <comments>http://community.livejournal.com/cpp/317202.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>siliconstitches</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/317053.html</guid>
  <pubDate>Thu, 12 Jun 2008 06:21:00 GMT</pubDate>
  <title>random</title>
  <link>http://community.livejournal.com/cpp/317053.html</link>
  <description>I am trying to write a program that reads from a file(easy) which contains names of restaurants, and their category. &lt;br /&gt;Now what I want to program to do is have a menu such as:&lt;br /&gt;&lt;br /&gt;Pick an option from the list below:&lt;br /&gt;[r]random restaurant&lt;br /&gt;[s]search restaurants by cetegory&lt;br /&gt;[a]add a restaurant to the database&lt;br /&gt;[d]delete a restaurant from the database&lt;br /&gt;[x]quit the program&lt;br /&gt;&lt;br /&gt;All I need help with here is the randomization. And for such a program should I use a dynamic character array, or a linked list?</description>
  <comments>http://community.livejournal.com/cpp/317053.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>everanddespair</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/316802.html</guid>
  <pubDate>Tue, 27 May 2008 19:51:53 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/316802.html</link>
  <description>I have never really cared about who-does what with my compiler/IDE so long as it does what it is supposed to. A friend suggested I gave Borland Turno C++ 2006 a go, so I did, and when I loadit p I get a start page not unlike MSVS.&lt;br /&gt;One thing it mentions is its using the Dinkumware STL library, so ... what is it. Dont the compilermakers write their own STL? I figure the STL is platform dependent in many places, which doesnt matter as long as its the same from the users point of view.</description>
  <comments>http://community.livejournal.com/cpp/316802.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lavandergirl</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/316297.html</guid>
  <pubDate>Wed, 30 Apr 2008 21:18:07 GMT</pubDate>
  <title>Sockets</title>
  <link>http://community.livejournal.com/cpp/316297.html</link>
  <description>Hey All!&lt;br /&gt;&lt;br /&gt;I was wondering if anyone knew a good tutorial for learning sockets, (or any method of communicating between two computers)? I use Bloodshed.net&apos;s Dev-Cpp Compiler, and would call myself a fairly intermediate-advanced programmer.&lt;br /&gt;&lt;br /&gt;Thanks!</description>
  <comments>http://community.livejournal.com/cpp/316297.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>photino40500</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/315931.html</guid>
  <pubDate>Sun, 20 Apr 2008 16:40:50 GMT</pubDate>
  <title>Help</title>
  <link>http://community.livejournal.com/cpp/315931.html</link>
  <description>Hello!&lt;br /&gt;&lt;br /&gt;I’m 16 and I&apos;m trying to teach myself C++. I&apos;m looking for a good program for newbies, preferably one with step by step instructions. I know there are several books available, but I’m more of a visual learner.&lt;br /&gt;&lt;br /&gt;Thanks in advance.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;P.S. I’m running on VISTA OS, but I also have an XP computer.</description>
  <comments>http://community.livejournal.com/cpp/315931.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>ashields124</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/315742.html</guid>
  <pubDate>Wed, 09 Apr 2008 01:55:20 GMT</pubDate>
  <title>Is there a way to determine if an object is an instance of a particular derived class?</title>
  <link>http://community.livejournal.com/cpp/315742.html</link>
  <description>I have a list of objects that are all instances of different classes that inherit the same base class.  All of these derived classes have member functions which are not in the base class, but which do more or less the same thing.  I&apos;d like to call the relevant function for each object, but I don&apos;t have a way of determining which objects are instances of which derived class.  Restructuring the inheritance hierarchy is not an option here, because these are all Qt classes.  Is there something in C++ that will allow me to test the objects to see if they are instances of certain classes?  I vaguely recall something called &quot;ofclass,&quot; but I don&apos;t remember if that was C++ or something else, and I haven&apos;t worked with inheritance in a long time.</description>
  <comments>http://community.livejournal.com/cpp/315742.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>oracular_rufio</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/315156.html</guid>
  <pubDate>Thu, 06 Mar 2008 18:11:05 GMT</pubDate>
  <title>HALP</title>
  <link>http://community.livejournal.com/cpp/315156.html</link>
  <description>Hi, just joined. I am in desperate need of help. I am taking an intro c++ class and am having a hard time on my 5th assignment. This one is waaay over my head. I took Intro the C before with the same teacher, and did well in the class. And I have been doing well in this class, but this assignment is kicking my ass. Anyway, this IS a homework assignment, so I am not fishing for people to do my homework for me(how else could I learn?) I just need a push. I am not really sure how to start. &lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;Write a C++ program to calculate and display the number of primes in the first 50 “chiliads”.  Your results should be as presented below, under testing.&lt;br /&gt;&lt;br /&gt;Start   End     Number of Primes&lt;br /&gt;1       1000    168&lt;br /&gt;1001    2000    135&lt;br /&gt;2001    3000    127&lt;br /&gt;3001    4000    120&lt;br /&gt;4001    5000    119&lt;br /&gt;5001    6000    114&lt;br /&gt;6001    7000    117&lt;br /&gt;7001    8000    107&lt;br /&gt;8001    9000    110&lt;br /&gt;9001    10000   112&lt;br /&gt;…&lt;br /&gt;…&lt;br /&gt;…&lt;br /&gt;49001   50000   98&lt;br /&gt;&lt;br /&gt;Total primes in the first 50 chiliads: 5133&lt;br /&gt;Average number per chiliad: 102.66&lt;br /&gt;&lt;br /&gt;She gave a bunch of background on chiliads, but that is unimportant. Basically a chaliad is an array of 1000 elements. So I have to count the number of primes in each chiliad and to total number of primes in all 50 chiliads. AND the average number of primes in each chiliad. BAH. &lt;br /&gt;&lt;br /&gt;So I have to use nested loops and functions(that is what this assignment is supposed to be practicing.) so I have two function prototypes(which my teacher gave):&lt;br /&gt;&lt;br /&gt;bool isPrime (long n);&lt;br /&gt;// Returns true if n is a prime, else false&lt;br /&gt;&lt;br /&gt;long primeCount (long x, long y);&lt;br /&gt;// Returns the number of primes between x and y, inclusive.&lt;br /&gt;&lt;br /&gt;I understand the concept of these functions, but I am not sure how to execute them.&lt;br /&gt;Can someone please help? An algorithm? hints? anything to push me in the right direction?&lt;br /&gt;&lt;br /&gt;EDIT: Here&apos;s what I have as of now:&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;
#include &amp;lt;iostream&amp;gt;

using namespace std;

bool isPrime(long n);
//returns true if n is prime, else false.

long primeCount(long x, long y);
//returns the number of primes between x and y.

int main()
{
        int i, j;

        for(i = 0; i &amp;lt;= 50; i++)
                for(j = 1; j &amp;lt;= 1000; j++)
                        isPrime(long);
        if(isPrime == true)
                primeCount();

        return 0;
}
bool isPrime(long n)
{
        for(int a = 1; a &amp;lt;= 50000; a++)
                if((n % a) == 0)
                        break;
        if(a == n)
                isPrime = true;
        else
                isPrime = false;
}

long primeCount(long x, long y)&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;I am now having trouble with primeCount. I&apos;m stuck on how to count the primes total, and the primes in each chiliad.</description>
  <comments>http://community.livejournal.com/cpp/315156.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>everanddespair</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/314953.html</guid>
  <pubDate>Wed, 27 Feb 2008 07:50:35 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/314953.html</link>
  <description>&lt;pre&gt;
NOTE: If you use C#, you probably feel the need for C++, if you use
C++ you may need Python, in a Python-project you&apos;ll learn the need for
Java, using Java, you will love C# or Fortran.  Or Assembler.  Or
simply commit suicide.  (Programming is a bitch.)
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;-- from &lt;a href=&quot;http://www.goolag.org/specifications.html&quot;&gt;Cult of the Dead Cow&apos;s specifications for Goolag Scanner&lt;/a&gt;</description>
  <comments>http://community.livejournal.com/cpp/314953.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>jmkelly</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/314675.html</guid>
  <pubDate>Mon, 18 Feb 2008 17:55:56 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/314675.html</link>
  <description>Anyone know much about Qt4? Thinking of using it for my (probably doomed to fail, but fun to try) IRC client. No difficult questions, just wondering if its as nice to use as it looks?</description>
  <comments>http://community.livejournal.com/cpp/314675.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lavandergirl</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/314131.html</guid>
  <pubDate>Tue, 12 Feb 2008 16:16:19 GMT</pubDate>
  <title>boost regex</title>
  <link>http://community.livejournal.com/cpp/314131.html</link>
  <description>I&apos;d appreciate any idea regarding the following &quot;find-and-replace&quot; functionality: I need a regular expression that would substitute every number, followed by some separator, with another number. There exists a function [int f(int)] converting input numbers into output ones. &lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;For instance, given the input:&lt;br /&gt;1,first,22,twenty two&lt;br /&gt;1,2,3,kuku,5&lt;br /&gt;some more text,5&lt;br /&gt;&lt;br /&gt;The output should be:&lt;br /&gt;7,first,33,twenty two&lt;br /&gt;7,12,13,kuku,10&lt;br /&gt;some more text,10&lt;br /&gt;&lt;br /&gt;If it&apos;s impossible to accomplish this &quot;at once&quot;, i.e. just by calling regex_replace(), then what would be the best way to do this, using boost regex?&lt;br /&gt;&lt;br /&gt;Thanks in advance!&lt;br /&gt;</description>
  <comments>http://community.livejournal.com/cpp/314131.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>iwr</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/313886.html</guid>
  <pubDate>Sat, 09 Feb 2008 20:10:38 GMT</pubDate>
  <title>Dowload data from Internet</title>
  <link>http://community.livejournal.com/cpp/313886.html</link>
  <description>Does anyone know how to download data&amp;nbsp; from the Internet using C++.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Namely, I would like to find a way to download data from Yahoo.Finance.Com. For example, S&amp;amp;P500, &lt;a href=&quot;http://finance.yahoo.com/q/hp?s=%5EGSPC&quot;&gt;http://finance.yahoo.com/q/hp?s=%5EGSPC&lt;/a&gt; for a specific period of time, and specific frequency. i know that this is possible in Excel/VBA. Thanks</description>
  <comments>http://community.livejournal.com/cpp/313886.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>alphaquantum</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/313563.html</guid>
  <pubDate>Wed, 23 Jan 2008 20:10:42 GMT</pubDate>
  <title>Linker troubles</title>
  <link>http://community.livejournal.com/cpp/313563.html</link>
  <description>I&apos;ve been writing a bunch of data structures to help myself get the hang of C++.  I generally separate it into three files: the header file, the implementation file, and file that has the main() function.&lt;br /&gt;&lt;br /&gt;However, I get a linker error if I don&apos;t put the implementations of the class methods in the main.cpp file, does anyone know what might be going wrong?</description>
  <comments>http://community.livejournal.com/cpp/313563.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>thelosthoplite</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/313191.html</guid>
  <pubDate>Thu, 10 Jan 2008 05:44:49 GMT</pubDate>
  <title>Need practice</title>
  <link>http://community.livejournal.com/cpp/313191.html</link>
  <description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;I just finished my second intro class in c++ the next step is data structures. I will not be taking it till fall 08 but i need to practice. Does anyone have any recommendations on what kind of program should i make? Nothing really complicated please.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thank you,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;chris&lt;/p&gt;</description>
  <comments>http://community.livejournal.com/cpp/313191.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>worldsoutro</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/312887.html</guid>
  <pubDate>Mon, 07 Jan 2008 21:30:13 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/312887.html</link>
  <description>I am having an odd error that I have not come up across before. My code compiles but doesn&apos;t link into an executable, whining about multiple definitions of the functions in the Client class. What am I doing wrong?

&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;
&lt;div class=&quot;cpp&quot; style=&quot;white-space: nowrap;border: 1px dotted #a0a0a0; font-family: &amp;#39;Courier New&amp;#39;, Courier, monospace; font-size: 110%; background-color: #f0f0f0; margin: 0; line-height: 110%; padding: 0;color: #000099;&quot;&gt;&lt;div class=&quot;head&quot;&gt;GeSHi &amp;copy; 2004, Nigel McNie&lt;/div&gt;&lt;ol&gt;&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// main.cpp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;Client.cpp&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; argc, &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;* argv&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Entry point&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Client ircc;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// Socket.cpp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#ifndef Socket_class&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#define Socket_class&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;sys/socket.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;netinet/in.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;netdb.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;unistd.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;arpa/inet.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; MAXHOSTNAME = &lt;span class=&quot;nu0&quot;&gt;200&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; MAXCONNECTIONS = &lt;span class=&quot;nu0&quot;&gt;5&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; MAXRECV = &lt;span class=&quot;nu0&quot;&gt;500&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Socket&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; Socket&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;virtual&lt;/span&gt; ~Socket&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// Server initialization&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; create&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; bind &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; listen&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; accept &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; Socket&amp;amp; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// Client initialization&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; connect &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt; host, &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// Data Transimission&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; send &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; recv &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; set_non_blocking &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; m_sock != &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt;; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; m_sock;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; sockaddr_in m_addr;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// Socket.cpp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;string&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;errno.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;Socket.h&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;Socket::&lt;span class=&quot;me2&quot;&gt;Socket&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; :&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_sock &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw3&quot;&gt;memset&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &amp;amp;m_addr,&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;kw3&quot;&gt;sizeof&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_addr &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;Socket::~Socket&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; ::&lt;span class=&quot;me2&quot;&gt;close&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_sock = socket &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; AF_INET,&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SOCK_STREAM,&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; ! is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;co1&quot;&gt;// TIME_WAIT - argh&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; on = &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; setsockopt &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, SOL_SOCKET, SO_REUSEADDR, &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;* &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &amp;amp;on, &lt;span class=&quot;kw3&quot;&gt;sizeof&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; on &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; == &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; ! is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_addr.&lt;span class=&quot;me1&quot;&gt;sin_family&lt;/span&gt; = AF_INET;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_addr.&lt;span class=&quot;me1&quot;&gt;sin_addr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;s_addr&lt;/span&gt; = INADDR_ANY;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_addr.&lt;span class=&quot;me1&quot;&gt;sin_port&lt;/span&gt; = htons &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; bind_return = ::&lt;span class=&quot;me2&quot;&gt;bind&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock,&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; sockaddr * &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &amp;amp;m_addr,&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;kw3&quot;&gt;sizeof&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_addr &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; bind_return == &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; ! is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; listen_return = ::&lt;span class=&quot;me2&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, MAXCONNECTIONS &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; listen_return == &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;accept&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; Socket&amp;amp; new_socket &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; addr_length = &lt;span class=&quot;kw3&quot;&gt;sizeof&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_addr &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; new_socket.&lt;span class=&quot;me1&quot;&gt;m_sock&lt;/span&gt; = ::&lt;span class=&quot;me2&quot;&gt;accept&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; sockaddr * &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &amp;amp;m_addr, &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; socklen_t * &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &amp;amp;addr_length &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; new_socket.&lt;span class=&quot;me1&quot;&gt;m_sock&lt;/span&gt; &amp;lt;= &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;send&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt; s &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; status = ::&lt;span class=&quot;me2&quot;&gt;send&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, s.&lt;span class=&quot;me1&quot;&gt;c_str&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;, s.&lt;span class=&quot;me1&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;, MSG_NOSIGNAL &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; status == &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;recv&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp; s &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; buf &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt; MAXRECV + &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; s = &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw3&quot;&gt;memset&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; buf, &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;, MAXRECV + &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; status = ::&lt;span class=&quot;me2&quot;&gt;recv&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, buf, MAXRECV, &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; status == &lt;span class=&quot;nu0&quot;&gt;-1&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;kw3&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;status == -1 &amp;nbsp; errno == &amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;kw2&quot;&gt;errno&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;nbsp;in Socket::recv&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; status == &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; s = buf;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; status;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;connect&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt; host, &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; ! is_valid&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_addr.&lt;span class=&quot;me1&quot;&gt;sin_family&lt;/span&gt; = AF_INET;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; m_addr.&lt;span class=&quot;me1&quot;&gt;sin_port&lt;/span&gt; = htons &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; port &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; status = inet_pton &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; AF_INET, host.&lt;span class=&quot;me1&quot;&gt;c_str&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;, &amp;amp;m_addr.&lt;span class=&quot;me1&quot;&gt;sin_addr&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;errno&lt;/span&gt; == EAFNOSUPPORT &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; status = ::&lt;span class=&quot;me2&quot;&gt;connect&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock, &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; sockaddr * &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &amp;amp;m_addr, &lt;span class=&quot;kw3&quot;&gt;sizeof&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_addr &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; status == &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; Socket::&lt;span class=&quot;me2&quot;&gt;set_non_blocking&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;bool&lt;/span&gt; b &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; opts;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; opts = fcntl &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock,&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F_GETFL &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; opts &amp;lt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; b &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; opts = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; opts | O_NONBLOCK &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; opts = &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; opts &amp;amp; ~O_NONBLOCK &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; fcntl &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; m_sock,&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F_SETFL,opts &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// client.h&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#ifndef _CLIENT_H_&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#define _CLIENT_H_&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;Socket.h&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; Client : &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; Socket&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Client&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; Client&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw2&quot;&gt;virtual&lt;/span&gt; ~Client&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; Client&amp;amp; operator &amp;lt;&amp;lt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; Client&amp;amp; operator &amp;gt;&amp;gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; accept&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Client&amp;amp;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// client.cpp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;Client.h&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;Client::&lt;span class=&quot;me2&quot;&gt;Client&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; port&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not create socket&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;port&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not bind to port.&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not listen to socket.&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;Client::~Client&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; Client&amp;amp; Client::&lt;span class=&quot;me2&quot;&gt;operator&lt;/span&gt; &amp;lt;&amp;lt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp; s&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not write to socket.&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; *&lt;span class=&quot;kw3&quot;&gt;this&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; Client&amp;amp; Client::&lt;span class=&quot;me2&quot;&gt;operator&lt;/span&gt; &amp;gt;&amp;gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;std::&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&amp;amp; s&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;recv&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not read from socket.&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; *&lt;span class=&quot;kw3&quot;&gt;this&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; Client::&lt;span class=&quot;me2&quot;&gt;accept&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Client&amp;amp; sock&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;!Socket::&lt;span class=&quot;me2&quot;&gt;accept&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;sock&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp; &amp;nbsp; std::&lt;span class=&quot;me2&quot;&gt;cout&lt;/span&gt;&amp;lt;&amp;lt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Could not accept socket.&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;li1&quot;&gt;&lt;div class=&quot;de1&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;foot&quot;&gt;Parsed in 0.238 seconds&lt;/div&gt;&lt;/div&gt;&lt;h4&gt;Statistics&lt;/h4&gt;
&lt;table class=&quot;tehTable&quot; cellspacing=&quot;1&quot;&gt;&lt;/table&gt;</description>
  <comments>http://community.livejournal.com/cpp/312887.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lavandergirl</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/312716.html</guid>
  <pubDate>Mon, 31 Dec 2007 21:57:37 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/312716.html</link>
  <description>Would an introductory book on C (the Waite Group&apos;s C Primer Plus) from 1990 be worth reading, or have the basics of the language changed too much?  The book&apos;s on generic (ANSI) C so there won&apos;t be worries about specific compilers or operating systems.&lt;br /&gt;&lt;br /&gt;Thanks in advance!&lt;br /&gt;&lt;br /&gt;EDIT: I&apos;ve already taken a quarter-long class in C++ and am signed up to take the second one next quarter.  I just want to do C for the fun of it.  :-)</description>
  <comments>http://community.livejournal.com/cpp/312716.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lilbrattyteen</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/312337.html</guid>
  <pubDate>Fri, 14 Dec 2007 10:14:06 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/312337.html</link>
  <description>I&apos;m just curious, as this one took me a bit to see and in fact was easier to see in assembly. I ran across something similar during a review and thought it was neat enough to share. The results have been interesting however, so knowing that there are some smart people in the community I figured I&apos;d ask and see what answers I got.&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;stdlib&amp;gt;
#include &amp;lt;windows.h&amp;gt;
#include &amp;lt;atlbase.h&amp;gt;


class doh_t
{

	public:
	
		LPCWSTR getter()
		{	
			return m_str ? m_str : L&quot;&quot;;
		}

	private:
		CComBSTR m_str;
};

int
main(void)
{

	LPCWSTR locStr;
	doh_t	doh;

	locStr = doh.getter();

	if (NULL != locStr) {
		if (! wcscmp(locStr, L&quot;&quot;)) {
			std::cout &amp;lt;&amp;lt; &quot;blank stringz :/&quot; &amp;lt;&amp;lt; std::endl;
			return EXIT_FAILURE;
		
		} else { // XXX not reached
			std::cout &amp;lt;&amp;lt; &quot;doh.getter() returned string: &quot; &amp;lt;&amp;lt; locStr &amp;lt;&amp;lt; std::endl;
			return EXIT_SUCCESS;
		}
	} else {
		std::cout &amp;lt;&amp;lt; &quot;doh.getter() returned null :((&quot; &amp;lt;&amp;lt; std::endl;
		return EXIT_FAILURE;
	}

	// XXX not reached
	return EXIT_FAILURE;
}
	
&lt;/pre&gt;&lt;br /&gt;</description>
  <comments>http://community.livejournal.com/cpp/312337.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>transgress</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/312233.html</guid>
  <pubDate>Tue, 11 Dec 2007 20:57:17 GMT</pubDate>
  <link>http://community.livejournal.com/cpp/312233.html</link>
  <description>This is a program that maintains a vector of record files.  It can read/write the records to/from a disk file and delete records.&lt;br /&gt;&lt;br /&gt;I put the read/write functions in the other day and all of a sudden it won&apos;t work.  It builds properly, but when I add records then try to display them, it says I don&apos;t have any records inputted.&lt;br /&gt;&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;html&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;
   1) /* 
   2)         comment the code!
   3)         perfect the remove-record functions
   4)         idiotproof input
   5) */
   6) 
   7) #include &amp;lt;iostream&amp;gt;
   8) #include &amp;lt;string&amp;gt;
   9) #include &amp;lt;vector&amp;gt;
  10) #include &amp;lt;fstream&amp;gt;
  11) using namespace std;
  12) 
  13) class InventoryRecord           //Defines record class.
  14) {
  15)         string Desc;
  16)         string ID;
  17)         float Cost;
  18)         string Location;
  19)         int Total;
  20) 
  21) public:
  22)         InventoryRecord() {;}           //Record class constructor.
  23)         
  24)         void SetDesc (string DescTemp) { Desc = DescTemp; }
  25)         void SetID (string IDTemp) { ID = IDTemp; }
  26)         void SetCost (string CostTemp) { Cost = atof(CostTemp.c_str()); }
  27)         void SetLocation (string LocationTemp) { Location = LocationTemp; }
  28)         void SetTotal (string TotalTemp) { Total = atoi(TotalTemp.c_str()); }
  29)         
  30)         string GetDesc() { return Desc; }
  31)         string GetID() { return ID; }
  32)         float GetCost() { return Cost; }
  33)         string GetLocation() { return Location; }
  34)         int GetTotal() { return Total; }
  35)         
  36)         void DisplayRecord();
  37) };
  38) 
  39) void InventoryRecord::DisplayRecord()           //Displays the contents of a record.
  40) {
  41)         cout &amp;lt;&amp;lt; &quot;\n===================================================&quot;;
  42)         cout &amp;lt;&amp;lt; &quot;\nThis is the entire record. &quot;;
  43)         cout &amp;lt;&amp;lt; &quot;\nItem ID: &quot; &amp;lt;&amp;lt; GetID();
  44)         cout &amp;lt;&amp;lt; &quot;\nItem description: &quot; &amp;lt;&amp;lt; GetDesc();
  45)         cout &amp;lt;&amp;lt; &quot;\nItem cost: &quot; &amp;lt;&amp;lt; GetCost();
  46)         cout &amp;lt;&amp;lt; &quot;\nItem location: &quot; &amp;lt;&amp;lt; GetLocation();
  47)         cout &amp;lt;&amp;lt; &quot;\nItem quantity: &quot; &amp;lt;&amp;lt; GetTotal();
  48)         cout &amp;lt;&amp;lt; &quot;\n===================================================&quot;;
  49) }
  50) 
  51) 
  52) class InventoryRecordVector                             //This class is a vector of record classes.  The vector manages the list of records.
  53) {
  54)         vector&amp;lt;InventoryRecord&amp;gt; RecordList;
  55)         
  56)         string DescTemp;
  57)         string IDTemp;
  58)         string CostTemp;
  59)         string LocationTemp;
  60)         string TotalTemp;
  61) 
  62) public:
  63)         InventoryRecordVector() {;}
  64)         vector&amp;lt;InventoryRecord&amp;gt;::iterator RecordListIterator;   //Defines the vector&apos;s iterator.
  65) 
  66)         void AddRecords();
  67)     void FindRecord();
  68)         void RemoveRecordsByID();
  69)         void RemoveRecordsByDescription();
  70)         void RemoveRecordsByCost();
  71)         void RemoveRecordsByLocation();
  72)         void RemoveRecordsByTotal();
  73)         void ShowRecords();
  74)         void OutputListToFile();
  75)         void LoadListFromFile();
  76)         void NewList();
  77) };
  78) 
  79) void InventoryRecordVector::AddRecords()                //Adds record objects to the end of the vector.
  80) { 
  81)         InventoryRecord RecordName;
  82) 
  83)         cout &amp;lt;&amp;lt; &quot;\nEnter records below.  Type &apos;stop&apos; to quit.&quot; &amp;lt;&amp;lt; endl;
  84) 
  85)         for(;;) 
  86)         {
  87)                 cout &amp;lt;&amp;lt; &quot;Item ID: &quot;;
  88)                 getline(cin, IDTemp);
  89)                 if(IDTemp  == &quot;Stop&quot; || IDTemp  == &quot;stop&quot;)
  90)                         break;
  91)         cout &amp;lt;&amp;lt; &quot;Item Description: &quot;;
  92)                 getline(cin, DescTemp);
  93)                 if(DescTemp  == &quot;Stop&quot; || DescTemp  == &quot;stop&quot;)
  94)                         break;
  95)                 cout &amp;lt;&amp;lt; &quot;Item Cost: &quot;;
  96)                 getline(cin, CostTemp);
  97)                 if(CostTemp  == &quot;Stop&quot; || CostTemp  == &quot;stop&quot;)
  98)                         break;
  99)                 cout &amp;lt;&amp;lt; &quot;Item Quantity: &quot;;
 100)                 getline(cin, TotalTemp);
 101)                 if(TotalTemp  == &quot;Stop&quot; || TotalTemp  == &quot;stop&quot;)
 102)                         break;
 103)                 cout &amp;lt;&amp;lt; &quot;Item Location: &quot;;
 104)                 getline(cin, LocationTemp);
 105)                 if(LocationTemp  == &quot;Stop&quot; || LocationTemp  == &quot;stop&quot;)
 106)                         break;
 107)         
 108)                 RecordName.SetDesc(DescTemp);
 109)                 RecordName.SetID(IDTemp);
 110)                 RecordName.SetCost(CostTemp);
 111)                 RecordName.SetTotal(TotalTemp);
 112)                 RecordName.SetLocation(LocationTemp);
 113) 
 114)                 RecordList.push_back(RecordName);
 115)         }
 116) }
 117) 
 118) void InventoryRecordVector::FindRecord()                //This will search for and display a record on the list..
 119) {
 120)         string SearchFor;
 121)         int SearchResults;
 122)         
 123)         cout &amp;lt;&amp;lt; &quot;\nThis search function will work with any of the record fields: ID, cost, description, quantity, and location.&quot;;
 124)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 125)         getline(cin, SearchFor);
 126)         
 127)         for(RecordListIterator = RecordList.begin() ; RecordListIterator != RecordList.end() ; RecordListIterator++)
 128)         {
 129)                 if(RecordListIterator-&amp;gt;GetDesc() == SearchFor) {
 130)                         RecordListIterator-&amp;gt;DisplayRecord();
 131)                         SearchResults++;   }
 132)                 if(RecordListIterator-&amp;gt;GetID() == SearchFor) {
 133)                         RecordListIterator-&amp;gt;DisplayRecord();
 134)                         SearchResults++;   }
 135)                 if(RecordListIterator-&amp;gt;GetCost() == atof(SearchFor.c_str())) {
 136)                         RecordListIterator-&amp;gt;DisplayRecord();
 137)                         SearchResults++;   }
 138)                 if(RecordListIterator-&amp;gt;GetLocation() == SearchFor) {
 139)                         RecordListIterator-&amp;gt;DisplayRecord();
 140)                         SearchResults++;   }
 141)                 if(RecordListIterator-&amp;gt;GetTotal() == atoi(SearchFor.c_str())) {
 142)                         RecordListIterator-&amp;gt;DisplayRecord();
 143)                         SearchResults++;   }
 144)         }
 145)         
 146)         if (SearchResults == 0)
 147)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot; Not Found&quot; &amp;lt;&amp;lt; endl;
 148) }
 149) 
 150) void InventoryRecordVector::RemoveRecordsByID()         //This function searches for records by the ID field and deletes them.
 151) {
 152)         string SearchFor;
 153)         int SearchResults, ToDeleteOrNotToDelete;
 154)         
 155)         cin.ignore(10, &apos;\n&apos;);
 156)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 157)         getline(cin, SearchFor);
 158)         
 159)         for (RecordListIterator = RecordList.begin() ; ; RecordListIterator++)
 160)         {
 161)                 if(RecordListIterator-&amp;gt;GetID() == SearchFor)
 162)                 {
 163)                         RecordListIterator-&amp;gt;DisplayRecord();
 164)                         SearchResults++;
 165)                         cout &amp;lt;&amp;lt; &quot;\nWould you like to delete this record?  Enter 1 if yes and 0 if no: &quot;;
 166)                         cin &amp;gt;&amp;gt; ToDeleteOrNotToDelete;
 167)                         if (ToDeleteOrNotToDelete == 1)  
 168)                         {
 169)                                 RecordList.erase(RecordListIterator);
 170)                                 cout &amp;lt;&amp;lt; &quot;\nRecord erased.&quot; &amp;lt;&amp;lt; endl;   
 171)                         }
 172)                         if (ToDeleteOrNotToDelete == 0)   
 173)                                 cout &amp;lt;&amp;lt; &quot;\nRecord saved.&quot; &amp;lt;&amp;lt; endl;
 174)                         else if ( (ToDeleteOrNotToDelete != 1) &amp;amp;&amp;amp; (ToDeleteOrNotToDelete == 0) )
 175)                                 cout &amp;lt;&amp;lt; &quot;Invalid input.&quot; &amp;lt;&amp;lt; endl;
 176)                 }       
 177)                         
 178)                 if (RecordListIterator == RecordList.end())
 179)                 {
 180)                         cout &amp;lt;&amp;lt; &quot;\nSearch done.&quot; &amp;lt;&amp;lt; endl;
 181)                         break;
 182)                 }
 183)         }
 184) 
 185)         if (SearchResults == 0)
 186)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot;\nNo results found.&quot; &amp;lt;&amp;lt; endl;
 187) }
 188) 
 189) 
 190) void InventoryRecordVector::RemoveRecordsByDescription()                //This function searches for records by the description field and deletes them.
 191) {
 192)         string SearchFor;
 193)         int SearchResults, ToDeleteOrNotToDelete;
 194)         
 195)         cin.ignore(10, &apos;\n&apos;);   
 196)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 197)         getline(cin, SearchFor);
 198)         
 199)         for (RecordListIterator = RecordList.begin() ; RecordListIterator != RecordList.end() ; RecordListIterator++)
 200)         {
 201)                 if(RecordListIterator-&amp;gt;GetDesc() == SearchFor)
 202)                 {
 203)                         RecordListIterator-&amp;gt;DisplayRecord();
 204)                         SearchResults++;
 205)                         cout &amp;lt;&amp;lt; &quot;\nWould you like to delete this record?  Enter 1 if yes and 0 if no: &quot;;
 206)                         cin &amp;gt;&amp;gt; ToDeleteOrNotToDelete;
 207)                         if (ToDeleteOrNotToDelete == 1)  {
 208)                                 RecordList.erase(RecordListIterator);
 209)                                 cout &amp;lt;&amp;lt; &quot;\nRecord erased.&quot; &amp;lt;&amp;lt; endl;   }
 210)                         if (ToDeleteOrNotToDelete == 0)   {
 211)                                 cout &amp;lt;&amp;lt; &quot;\nRecord saved.&quot; &amp;lt;&amp;lt; endl;
 212)                         }
 213)                         else if ( (ToDeleteOrNotToDelete != 1) &amp;amp;&amp;amp; (ToDeleteOrNotToDelete == 0) )
 214)                                 cout &amp;lt;&amp;lt; &quot;Invalid input.&quot; &amp;lt;&amp;lt; endl;
 215)                 }
 216)         }
 217) 
 218)         if (SearchResults == 0)
 219)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot; Not Found&quot; &amp;lt;&amp;lt; endl;
 220) }
 221) 
 222) void InventoryRecordVector::RemoveRecordsByCost()               //This function searches for records by the cost field and deletes them.
 223) {
 224)         float SearchFor;
 225)         int SearchResults, ToDeleteOrNotToDelete;
 226) 
 227)         cin.ignore(10, &apos;\n&apos;);   
 228)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 229)         cin &amp;gt;&amp;gt; SearchFor;
 230)         
 231)         for (RecordListIterator = RecordList.begin() ; RecordListIterator != RecordList.end() ; RecordListIterator++)
 232)         {
 233)                 if(RecordListIterator-&amp;gt;GetCost() == SearchFor)
 234)                 {
 235)                         RecordListIterator-&amp;gt;DisplayRecord();
 236)                         SearchResults++;
 237)                         cout &amp;lt;&amp;lt; &quot;\nWould you like to delete this record?  Enter 1 if yes and 0 if no: &quot;;
 238)                         cin &amp;gt;&amp;gt; ToDeleteOrNotToDelete;
 239)                         if (ToDeleteOrNotToDelete == 1)  {
 240)                                 RecordList.erase(RecordListIterator);
 241)                                 cout &amp;lt;&amp;lt; &quot;\nRecord erased.&quot; &amp;lt;&amp;lt; endl;   }
 242)                         if (ToDeleteOrNotToDelete == 0)   {
 243)                                 cout &amp;lt;&amp;lt; &quot;\nRecord saved.&quot; &amp;lt;&amp;lt; endl;
 244)                                 break;   }
 245)                         else if ( (ToDeleteOrNotToDelete != 1) &amp;amp;&amp;amp; (ToDeleteOrNotToDelete == 0) )
 246)                                 cout &amp;lt;&amp;lt; &quot;Invalid input.&quot; &amp;lt;&amp;lt; endl;
 247)                 }
 248)         }
 249) 
 250)         if (SearchResults == 0)
 251)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot; Not Found&quot; &amp;lt;&amp;lt; endl;
 252) }
 253) 
 254) void InventoryRecordVector::RemoveRecordsByLocation()           //This function searches for records by the location field and deletes them.
 255) {
 256)         string SearchFor;
 257)         int SearchResults, ToDeleteOrNotToDelete;
 258) 
 259)         cin.ignore(10, &apos;\n&apos;);   
 260)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 261)         getline(cin, SearchFor);
 262)         
 263)         for (RecordListIterator = RecordList.begin() ; RecordListIterator != RecordList.end() ; RecordListIterator++)
 264)         {
 265)                 if(RecordListIterator-&amp;gt;GetLocation() == SearchFor)
 266)                 {
 267)                         RecordListIterator-&amp;gt;DisplayRecord();
 268)                         SearchResults++;
 269)                         cout &amp;lt;&amp;lt; &quot;\nWould you like to delete this record?  Enter 1 if yes and 0 if no: &quot;;
 270)                         cin &amp;gt;&amp;gt; ToDeleteOrNotToDelete;
 271)                         if (ToDeleteOrNotToDelete == 1)  {
 272)                                 RecordList.erase(RecordListIterator);
 273)                                 cout &amp;lt;&amp;lt; &quot;\nRecord erased.&quot; &amp;lt;&amp;lt; endl;   }
 274)                         if (ToDeleteOrNotToDelete == 0)   {
 275)                                 cout &amp;lt;&amp;lt; &quot;\nRecord saved.&quot; &amp;lt;&amp;lt; endl;
 276)                                 break;   }
 277)                         else if ( (ToDeleteOrNotToDelete != 1) &amp;amp;&amp;amp; (ToDeleteOrNotToDelete == 0) )
 278)                                 cout &amp;lt;&amp;lt; &quot;Invalid input.&quot; &amp;lt;&amp;lt; endl;
 279)                 }
 280)         }
 281) 
 282)         if (SearchResults == 0)
 283)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot; Not Found&quot; &amp;lt;&amp;lt; endl;
 284) }
 285) 
 286) void InventoryRecordVector::RemoveRecordsByTotal()              //This function searches for records by the quantity field and deletes them.
 287) {
 288)         int SearchFor, SearchResults, ToDeleteOrNotToDelete;
 289) 
 290)         cin.ignore(10, &apos;\n&apos;);   
 291)         cout &amp;lt;&amp;lt; &quot;\nEnter Search Value: &quot;;
 292)         cin &amp;gt;&amp;gt; SearchFor;
 293)         
 294)         for (RecordListIterator = RecordList.begin() ; RecordListIterator != RecordList.end() ; RecordListIterator++)
 295)         {
 296)                 if(RecordListIterator-&amp;gt;GetTotal() == SearchFor)
 297)                 {
 298)                         RecordListIterator-&amp;gt;DisplayRecord();
 299)                         SearchResults++;
 300)                         cout &amp;lt;&amp;lt; &quot;\nWould you like to delete this record?  Enter 1 if yes and 0 if no: &quot;;
 301)                         cin &amp;gt;&amp;gt; ToDeleteOrNotToDelete;
 302)                         if (ToDeleteOrNotToDelete == 1)  {
 303)                                 RecordList.erase(RecordListIterator);
 304)                                 cout &amp;lt;&amp;lt; &quot;\nRecord erased.&quot; &amp;lt;&amp;lt; endl;   }
 305)                         if (ToDeleteOrNotToDelete == 0)   {
 306)                                 cout &amp;lt;&amp;lt; &quot;\nRecord saved.&quot; &amp;lt;&amp;lt; endl;
 307)                                 break;   }
 308)                         else if ( (ToDeleteOrNotToDelete != 1) &amp;amp;&amp;amp; (ToDeleteOrNotToDelete == 0) )
 309)                                 cout &amp;lt;&amp;lt; &quot;Invalid input.&quot; &amp;lt;&amp;lt; endl;
 310)                 }
 311)         }
 312) 
 313)         if (SearchResults == 0)
 314)                 cout &amp;lt;&amp;lt; SearchFor &amp;lt;&amp;lt; &quot; Not Found&quot; &amp;lt;&amp;lt; endl;
 315) }
 316) 
 317) void InventoryRecordVector::ShowRecords()               //This member function will display the entire contents of the vector.
 318) {
 319)         if (RecordList.empty())
 320)         {
 321)                 cout &amp;lt;&amp;lt; &quot;\nThe list has no elements.&quot; &amp;lt;&amp;lt; endl;
 322)                 return;
 323)         }
 324)         for(RecordListIterator = RecordList.begin() ; ; RecordListIterator++)
 325)         {
 326)                 RecordListIterator-&amp;gt;DisplayRecord();
 327)                 if (RecordListIterator == RecordList.end())
 328)                 {
 329)                         cout &amp;lt;&amp;lt; &quot;\nSearch done.&quot; &amp;lt;&amp;lt; endl;
 330)                         break;
 331)                 }
 332)         }
 333) }
 334) 
 335) void InventoryRecordVector::OutputListToFile()
 336) {
 337)         fstream OutputToFile(&quot;List&quot;, ios::out);
 338)         
 339)         for(RecordListIterator = RecordList.begin() ; ; RecordListIterator++)
 340)         {
 341)                 OutputToFile &amp;lt;&amp;lt; RecordListIterator-&amp;gt;GetDesc() &amp;lt;&amp;lt; endl;
 342)                 OutputToFile &amp;lt;&amp;lt; RecordListIterator-&amp;gt;GetID() &amp;lt;&amp;lt; endl;
 343)                 OutputToFile &amp;lt;&amp;lt; RecordListIterator-&amp;gt;GetCost() &amp;lt;&amp;lt; endl;
 344)                 OutputToFile &amp;lt;&amp;lt; RecordListIterator-&amp;gt;GetLocation() &amp;lt;&amp;lt; endl;
 345)                 OutputToFile &amp;lt;&amp;lt; RecordListIterator-&amp;gt;GetTotal() &amp;lt;&amp;lt; endl;
 346)                 if (RecordListIterator == RecordList.end())
 347)                 {
 348)                         cout &amp;lt;&amp;lt; &quot;\nSearch done.&quot; &amp;lt;&amp;lt; endl;
 349)                         break;
 350)                 }
 351)         }
 352)         
 353)         OutputToFile.close();
 354)         
 355)         cout &amp;lt;&amp;lt; &quot;\nFile saved.&quot; &amp;lt;&amp;lt; endl;
 356) }
 357) 
 358) void InventoryRecordVector::LoadListFromFile()          //This member function loads the contents of the vector from the contents of a file.
 359) {
 360)         fstream InputFromFile(&quot;List&quot;, ios::in);
 361)         
 362)         for ( ; ; )
 363)         {
 364)                 InventoryRecord RecordName;
 365)                 
 366)                 getline(InputFromFile, DescTemp);
 367)                 RecordName.SetDesc(DescTemp);
 368)                 
 369)                 getline(InputFromFile, IDTemp);
 370)                 RecordName.SetID(IDTemp);
 371)                 
 372)                 getline(InputFromFile, CostTemp);
 373)                 RecordName.SetCost(CostTemp);
 374)                 
 375)                 getline(InputFromFile, LocationTemp);
 376)                 RecordName.SetLocation(LocationTemp);
 377)                 
 378)                 getline(InputFromFile, TotalTemp);
 379)                 RecordName.SetTotal(TotalTemp);
 380)                 
 381)                 RecordList.push_back(RecordName);
 382)                 
 383)                 if(InputFromFile.eof())                         //This is true just in case the program
 384)                         break;                                                  //   is at the end of the file...
 385)         }       
 386)         
 387)         InputFromFile.close();
 388)         
 389)         cout &amp;lt;&amp;lt; &quot;\nFile loaded.&quot; &amp;lt;&amp;lt; endl;
 390) }
 391) 
 392) void InventoryRecordVector::NewList()
 393) {
 394)         RecordList.clear();
 395)         cout &amp;lt;&amp;lt; &quot;\nNew empty list created.&quot; &amp;lt;&amp;lt; endl;
 396) }
 397) 
 398) 
 399) 
 400) 
 401) 
 402) 
 403) 
 404) 
 405) 
 406) 
 407) 
 408) 
 409) 
 410) 
 411) 
 412) 
 413) 
 414) 
 415) 
 416) 
 417) 
 418) 
 419) 
 420) void Menu();                                                                    //Declaring and defining the main functions of the program.
 421) int MenuResults(string Cmd, int M, InventoryRecordVector List);
 422) void RemoveRecords(InventoryRecordVector List);
 423) 
 424) int main()                                                                                      //Finally, the main program!
 425) {
 426)         InventoryRecordVector List;
 427)         int M=0;
 428)         string Cmd;
 429) 
 430)         while(true) 
 431)         {
 432)                 Menu();
 433)                 cout &amp;lt;&amp;lt; &quot;\nSelect command: &quot;;
 434)                 getline(cin, Cmd);
 435)                 
 436)                 if(Cmd == &quot;Quit&quot; || Cmd == &quot;quit&quot;)
 437)                         break;
 438)                 
 439)                 M = MenuResults(Cmd, M, List);
 440)                 if (M == 2)
 441)                         RemoveRecords(List);
 442)                 if (M == 0)
 443)                         cout &amp;lt;&amp;lt; &quot;\nInvalid command.&quot; &amp;lt;&amp;lt; endl;
 444)         }
 445) }
 446) 
 447) void Menu()                                                                             //Displays the menu of the program.
 448) {
 449)         cout &amp;lt;&amp;lt; &quot;\n\n\n========================================================&quot;;
 450)         cout &amp;lt;&amp;lt; &quot;\nChoices:&quot; &amp;lt;&amp;lt; endl;
 451)         cout &amp;lt;&amp;lt; &quot;Add\t\tAdd records to the list&quot; &amp;lt;&amp;lt; endl;
 452)         cout &amp;lt;&amp;lt; &quot;Find\tSearch for a particular record&quot; &amp;lt;&amp;lt; endl;
 453)         cout &amp;lt;&amp;lt; &quot;Remove\tDelete a record from the list&quot; &amp;lt;&amp;lt; endl;
 454)         cout &amp;lt;&amp;lt; &quot;Show\tDisplay all the records on the list&quot; &amp;lt;&amp;lt; endl;
 455)         cout &amp;lt;&amp;lt; &quot;Save\tSave list as a plain-format ASCII file&quot; &amp;lt;&amp;lt; endl;
 456)         cout &amp;lt;&amp;lt; &quot;Load\tLoad list from a previously-saved ASCII file and add contents to end of current list&quot; &amp;lt;&amp;lt; endl;
 457)         cout &amp;lt;&amp;lt; &quot;New\t\tClear current list and restart with a new list&quot; &amp;lt;&amp;lt; endl;
 458)         cout &amp;lt;&amp;lt; &quot;Quit&quot; &amp;lt;&amp;lt; endl;
 459)         cout &amp;lt;&amp;lt; &quot;========================================================&quot;;
 460) }
 461) 
 462) int MenuResults(string Cmd, int M, InventoryRecordVector List)
 463) {
 464)         M=0;
 465) 
 466)         if(Cmd == &quot;Add&quot; || Cmd == &quot;add&quot;)
 467)         {
 468)                 M=1;
 469)                 List.AddRecords();
 470)         }
 471)         if(Cmd == &quot;Find&quot; || Cmd == &quot;find&quot;)
 472)         {
 473)                 M=1;
 474)                 List.FindRecord();
 475)         }
 476)     if(Cmd == &quot;Remove&quot; || Cmd == &quot;remove&quot;)
 477)         {
 478)                 M=2;
 479)         }
 480)         if(Cmd == &quot;Show&quot; || Cmd == &quot;show&quot;)
 481)         {
 482)                 M=1;
 483)                 List.ShowRecords();
 484)         }
 485)         if(Cmd == &quot;Save&quot; || Cmd == &quot;save&quot;)
 486)         {
 487)                 M=1;
 488)                 List.OutputListToFile();
 489)         }
 490)         if(Cmd == &quot;Load&quot; || Cmd == &quot;load&quot;)
 491)         {
 492)                 M=1;
 493)                 List.LoadListFromFile();
 494)         }
 495)         if(Cmd == &quot;New&quot; || Cmd == &quot;new&quot;)
 496)         {
 497)                 M=1;
 498)                 List.NewList();
 499)         }
 500)         return M;
 501) }
 502) 
 503) void RemoveRecords(InventoryRecordVector List)                  //Displays the submenu used to remove objects from the vector.
 504) {
 505)         string Choice;
 506)         int L;
 507)         
 508)         cout &amp;lt;&amp;lt; &quot;\n========================================================&quot;;
 509)         cout &amp;lt;&amp;lt; &quot;\nWays to remove records:&quot; &amp;lt;&amp;lt; endl;
 510)         cout &amp;lt;&amp;lt; &quot;1\tRemove by ID.&quot; &amp;lt;&amp;lt; endl;
 511)         cout &amp;lt;&amp;lt; &quot;2\tRemove by description.&quot; &amp;lt;&amp;lt; endl;    
 512)         cout &amp;lt;&amp;lt; &quot;3\tRemove by cost.&quot; &amp;lt;&amp;lt; endl;
 513)         cout &amp;lt;&amp;lt; &quot;4\tRemove by location.&quot; &amp;lt;&amp;lt; endl;
 514)         cout &amp;lt;&amp;lt; &quot;5\tRemove by quantity.&quot; &amp;lt;&amp;lt; endl;
 515)         cout &amp;lt;&amp;lt; &quot;6\tQuit&quot; &amp;lt;&amp;lt; endl;
 516)         cout &amp;lt;&amp;lt; &quot;========================================================&quot;;
 517)         cout &amp;lt;&amp;lt; &quot;\n\nPlease enter your choice, then hit enter twice:  &quot;;
 518)         
 519)         getline(cin, Choice);
 520)         
 521)         
 522)         if (Choice == &quot;1&quot; || Choice == &quot;ID&quot; || Choice == &quot;id&quot;)
 523)         {
 524)                 L++;
 525)                 List.RemoveRecordsByID();
 526)         }
 527)         if (Choice == &quot;2&quot; || Choice == &quot;description&quot; || Choice == &quot;Description&quot;)
 528)         {
 529)                 L++;
 530)                 List.RemoveRecordsByDescription();
 531)         }
 532)         if (Choice == &quot;3&quot; || Choice == &quot;cost&quot; || Choice == &quot;Cost&quot;)
 533)         {
 534)                 L++;
 535)                 List.RemoveRecordsByCost();
 536)         }
 537)         if (Choice == &quot;4&quot; || Choice == &quot;location&quot; || Choice == &quot;Location&quot;)
 538)         {
 539)                 L++;
 540)                 List.RemoveRecordsByLocation();
 541)         }
 542)         if (Choice == &quot;5&quot; || Choice == &quot;quantity&quot; || Choice == &quot;Quantity&quot;)
 543)         {
 544)                 L++;
 545)                 List.RemoveRecordsByTotal();
 546)         }
 547)         if (Choice == &quot;6&quot; || Choice == &quot;quit&quot; || Choice == &quot;Quit&quot;)
 548)                 return;
 549)         if (L == 0)
 550)                 cout &amp;lt;&amp;lt; &quot;Invalid choice, back to main menu.&quot; &amp;lt;&amp;lt; endl;
 551) }&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
  <comments>http://community.livejournal.com/cpp/312233.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>lilbrattyteen</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/311869.html</guid>
  <pubDate>Fri, 07 Dec 2007 07:16:47 GMT</pubDate>
  <title>Joel</title>
  <link>http://community.livejournal.com/cpp/311869.html</link>
  <description>Something all of you would be software types should read.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.joelonsoftware.com/items/2007/12/03.html&quot;&gt;An talk by Joel at Yale.&lt;/a&gt;</description>
  <comments>http://community.livejournal.com/cpp/311869.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>redslime</lj:poster>
</item>
<item>
  <guid isPermaLink='true'>http://community.livejournal.com/cpp/311741.html</guid>
  <pubDate>Tue, 04 Dec 2007 12:40:51 GMT</pubDate>
  <title>Save avi video stream in separate file (vfw.h)</title>
  <link>http://community.livejournal.com/cpp/311741.html</link>
  <description>I&apos;ve done some code, but extracted video stream is very large (15mb-&amp;gt;1GB) and won&apos;t play in media players. But in properties all looks good the same time resolution ...&lt;br /&gt;&lt;a name=&quot;cutid1&quot;&gt;&lt;/a&gt;&lt;br /&gt;There is my try:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;void SaveStream(PAVISTREAM ps, LPSTR lpFilename) &lt;br /&gt;{ &lt;br /&gt;    PAVIFILE            pf; &lt;br /&gt;    PAVISTREAM          psAvi;&lt;br /&gt;    HRESULT             hr;&lt;br /&gt;    AVISTREAMINFO       strhdr;&lt;br /&gt;    BITMAPINFOHEADER    bi,&lt;br /&gt;                        biNew;&lt;br /&gt;    LONG                lStreamSize;&lt;br /&gt;    LPVOID              lpOld,&lt;br /&gt;                        lpNew;&lt;br /&gt; &lt;br /&gt;    // AVIStreamFormatSize. &lt;br /&gt;    AVIStreamFormatSize(ps, 0, &amp;lStreamSize); &lt;br /&gt;    if (lStreamSize &amp;gt; sizeof(bi)) // Format too large? &lt;br /&gt;        return; &lt;br /&gt; &lt;br /&gt;    lStreamSize = sizeof(bi); &lt;br /&gt;    hr = AVIStreamReadFormat(ps, 0, &amp;bi, &amp;lStreamSize); // &lt;br /&gt;&lt;br /&gt;    String msg = &quot;&quot;;&lt;br /&gt;    switch (bi.biCompression)&lt;br /&gt;       {&lt;br /&gt;         case BI_RGB: msg = &quot;Uncompressed&quot;;&lt;br /&gt;         case BI_RLE8:  msg = &quot;RLE 8 &quot;;&lt;br /&gt;         case BI_RLE4:  msg = &quot;RLE 4 &quot;;&lt;br /&gt;         case BI_BITFIELDS:  msg = &quot;16,32-uncompr&quot;;&lt;br /&gt;         case BI_JPEG:  msg = &quot;JPEG&quot;;&lt;br /&gt;         case BI_PNG:  msg = &quot;PNG&quot;;&lt;br /&gt;         default: msg = &quot;Unknown!&quot;;&lt;br /&gt;       }&lt;br /&gt;    ShowMessage(msg);&lt;br /&gt;&lt;br /&gt;    hr = AVIStreamInfo(ps, &amp;strhdr, sizeof(strhdr)); //  &lt;br /&gt; &lt;br /&gt;    // AVIFileOpen. &lt;br /&gt;    hr = AVIFileOpen(&amp;pf, lpFilename, OF_WRITE | OF_CREATE, NULL); &lt;br /&gt;    if (hr != 0) &lt;br /&gt;        return; &lt;br /&gt; &lt;br /&gt;    // &lt;br /&gt;    biNew = bi;&lt;br /&gt;    biNew.biCompression = 0; //&lt;br /&gt;    //  AVIFileCreateStream. &lt;br /&gt;    hr = AVIFileCreateStream(pf, &amp;psAvi, &amp;strhdr); &lt;br /&gt;    if (hr != 0) {            // &lt;br /&gt;        AVIFileRelease(pf); &lt;br /&gt;        return; &lt;br /&gt;    } &lt;br /&gt; &lt;br /&gt;    // AVIStreamSetFormat. &lt;br /&gt;    hr = AVIStreamSetFormat(psAvi, 0, &amp;biNew, sizeof(biNew)); &lt;br /&gt;    if (hr != 0) { // &lt;br /&gt;        AVIStreamRelease(psAvi); &lt;br /&gt;        AVIFileRelease(pf); &lt;br /&gt;        return; &lt;br /&gt;    } &lt;br /&gt; &lt;br /&gt;    // &lt;br /&gt;    lpOld = GlobalAllocPtr(GMEM_MOVEABLE, bi.biSizeImage); &lt;br /&gt;    lpNew = GlobalAllocPtr(GMEM_MOVEABLE, biNew.biSizeImage); &lt;br /&gt; &lt;br /&gt;    // Read the stream data using AVIStreamRead. &lt;br /&gt;    for (lStreamSize = AVIStreamStart(ps); lStreamSize &amp;lt;&lt;br /&gt;        AVIStreamEnd(ps); lStreamSize++) { &lt;br /&gt;        hr = AVIStreamRead(ps, lStreamSize, 1, lpOld, bi.biSizeImage,&lt;br /&gt;            NULL, NULL); &lt;br /&gt;        if (hr != 0) { // н&lt;br /&gt;            AVIStreamRelease(psAvi);&lt;br /&gt;            AVIFileRelease(pf);&lt;br /&gt;            return;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        //  AVIStreamWrite. &lt;br /&gt;        hr = AVIStreamWrite(psAvi, lStreamSize, 1, lpNew,&lt;br /&gt;            biNew.biSizeImage, AVIIF_KEYFRAME, NULL, NULL); &lt;br /&gt;    } &lt;br /&gt; &lt;br /&gt;     // &lt;br /&gt;    AVIStreamRelease(psAvi); &lt;br /&gt;    AVIFileRelease(pf); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void __fastcall TForm1::FormCreate(TObject *Sender)&lt;br /&gt;{&lt;br /&gt;    PAVISTREAM pVideoStream;&lt;br /&gt;    &lt;br /&gt;    bool bFileOpen;&lt;br /&gt;    if(OpenDialog1-&amp;gt;Execute()) {&lt;br /&gt;       &lt;br /&gt;            long r, fmtlen;&lt;br /&gt;            AVIFileInit();&lt;br /&gt;            r = AVIStreamOpenFromFile(&amp;pVideoStream, OpenDialog1-&amp;gt;FileName.c_str(),&lt;br /&gt;                  streamtypeVIDEO, 0, OF_READ | OF_SHARE_EXCLUSIVE, 0);&lt;br /&gt;            if(r!=0) ShowMes