Click here to Skip to main content
15,881,898 members
Articles / Desktop Programming / MFC

Handling Multiple Pending Socket Read and Write Operations

Rate me:
Please Sign up or sign in to vote.
4.90/5 (28 votes)
17 Aug 2002CPOL13 min read 688.3K   8.8K   153  
This article explains the potential problems with having multiple pending recvs calls on a single socket.
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="7.00"
	Name="Win32Tools"
	SccProjectName="&quot;$/Web Articles/SocketServers/ServerShutdown/JetByteTools/Win32Tools&quot;, CNAAAAAA"
	SccAuxPath=""
	SccLocalPath="."
	SccProvider="MSSCCI:Microsoft Visual SourceSafe">
	<Platforms>
		<Platform
			Name="Win32"/>
	</Platforms>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory=".\Output\VC7\Debug"
			IntermediateDirectory=".\Output\VC7\Debug"
			ConfigurationType="4"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="..\..\"
				PreprocessorDefinitions="_DEBUG,_LIB,WIN32,_WIN32_WINNT=0x0400"
				BasicRuntimeChecks="3"
				RuntimeLibrary="1"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\Output\VC7\Debug/Win32Tools.pch"
				AssemblerListingLocation=".\Output\VC7\Debug/"
				ObjectFile=".\Output\VC7\Debug/"
				ProgramDataBaseFileName=".\Output\VC7\Debug/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				DebugInformationFormat="4"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile=".\Output\VC7\Debug\Win32Tools.lib"
				SuppressStartupBanner="TRUE"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="2057"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Unicode Debug|Win32"
			OutputDirectory=".\Output\VC7\UDebug"
			IntermediateDirectory=".\Output\VC7\UDebug"
			ConfigurationType="4"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="1">
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="..\..\"
				PreprocessorDefinitions="_DEBUG,UNICODE,_LIB,WIN32,_MBCS,_WIN32_WINNT=0x0400"
				BasicRuntimeChecks="3"
				RuntimeLibrary="1"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\Output\VC7\UDebug/Win32Tools.pch"
				AssemblerListingLocation=".\Output\VC7\UDebug/"
				ObjectFile=".\Output\VC7\UDebug/"
				ProgramDataBaseFileName=".\Output\VC7\UDebug/"
				BrowseInformation="1"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				DebugInformationFormat="4"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile=".\Output\VC7\UDebug\Win32Tools.lib"
				SuppressStartupBanner="TRUE"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="2057"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory=".\Output\VC7\Release"
			IntermediateDirectory=".\Output\VC7\Release"
			ConfigurationType="4"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="2">
			<Tool
				Name="VCCLCompilerTool"
				InlineFunctionExpansion="1"
				AdditionalIncludeDirectories="..\..\"
				PreprocessorDefinitions="NDEBUG,_LIB,WIN32,_WIN32_WINNT=0x0400"
				StringPooling="TRUE"
				RuntimeLibrary="0"
				EnableFunctionLevelLinking="TRUE"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\Output\VC7\Release/Win32Tools.pch"
				AssemblerListingLocation=".\Output\VC7\Release/"
				ObjectFile=".\Output\VC7\Release/"
				ProgramDataBaseFileName=".\Output\VC7\Release/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile=".\Output\VC7\Release\Win32Tools.lib"
				SuppressStartupBanner="TRUE"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="NDEBUG"
				Culture="2057"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
		</Configuration>
		<Configuration
			Name="Unicode Release|Win32"
			OutputDirectory=".\Output\VC7\URelease"
			IntermediateDirectory=".\Output\VC7\URelease"
			ConfigurationType="4"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="FALSE"
			CharacterSet="1">
			<Tool
				Name="VCCLCompilerTool"
				InlineFunctionExpansion="1"
				AdditionalIncludeDirectories="..\..\"
				PreprocessorDefinitions="NDEBUG,UNICODE,_LIB,WIN32,_MBCS,_WIN32_WINNT=0x0400"
				StringPooling="TRUE"
				RuntimeLibrary="0"
				EnableFunctionLevelLinking="TRUE"
				UsePrecompiledHeader="2"
				PrecompiledHeaderFile=".\Output\VC7\URelease/Win32Tools.pch"
				AssemblerListingLocation=".\Output\VC7\URelease/"
				ObjectFile=".\Output\VC7\URelease/"
				ProgramDataBaseFileName=".\Output\VC7\URelease/"
				WarningLevel="3"
				SuppressStartupBanner="TRUE"
				CompileAs="0"/>
			<Tool
				Name="VCCustomBuildTool"/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile=".\Output\VC7\URelease\Win32Tools.lib"
				SuppressStartupBanner="TRUE"/>
			<Tool
				Name="VCMIDLTool"/>
			<Tool
				Name="VCPostBuildEventTool"/>
			<Tool
				Name="VCPreBuildEventTool"/>
			<Tool
				Name="VCPreLinkEventTool"/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="NDEBUG"
				Culture="2057"/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"/>
		</Configuration>
	</Configurations>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
			<File
				RelativePath=".\CriticalSection.cpp">
			</File>
			<File
				RelativePath=".\Event.cpp">
			</File>
			<File
				RelativePath=".\Exception.cpp">
			</File>
			<File
				RelativePath=".\ManualResetEvent.cpp">
			</File>
			<File
				RelativePath=".\Utils.cpp">
			</File>
			<File
				RelativePath=".\Win32Exception.cpp">
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl">
			<File
				RelativePath=".\CriticalSection.h">
			</File>
			<File
				RelativePath=".\Event.h">
			</File>
			<File
				RelativePath=".\Exception.h">
			</File>
			<File
				RelativePath=".\ManualResetEvent.h">
			</File>
			<File
				RelativePath=".\Utils.h">
			</File>
			<File
				RelativePath=".\Win32Exception.h">
			</File>
			<File
				RelativePath=".\tstring.h">
			</File>
		</Filter>
		<Filter
			Name="Lint Options"
			Filter="">
			<File
				RelativePath=".\Win32Tools.lnt">
			</File>
			<File
				RelativePath=".\std.lnt">
			</File>
		</Filter>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) JetByte Limited
United Kingdom United Kingdom
Len has been programming for over 30 years, having first started with a Sinclair ZX-80. Now he runs his own consulting company, JetByte Limited and has a technical blog here.

JetByte provides contract programming and consultancy services. We can provide experience in COM, Corba, C++, Windows NT and UNIX. Our speciality is the design and implementation of systems but we are happy to work with you throughout the entire project life-cycle. We are happy to quote for fixed price work, or, if required, can work for an hourly rate.

We are based in London, England, but, thanks to the Internet, we can work 'virtually' anywhere...

Please note that many of the articles here may have updated code available on Len's blog and that the IOCP socket server framework is also available in a licensed, much improved and fully supported version, see here for details.

Comments and Discussions