submitted 1.2.0

This commit is contained in:
Guenter Obiltschnig
2006-08-29 07:10:35 +00:00
parent f476bd6b32
commit 2d4078f392
1428 changed files with 25715 additions and 12456 deletions

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/EchoServer/EchoServer.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/EchoServer/EchoServer.vmsbuild#1 $
#
EXE=EchoServer
EchoServer

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/EchoServer/Makefile#1 $
# $Id: //poco/1.2/Net/samples/EchoServer/Makefile#1 $
#
# Makefile for Poco EchoServer
#
@@ -12,6 +12,6 @@ objects = EchoServer
target = EchoServer
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
//
// EchoServer.cpp
//
// $Id: //poco/1.1.0/Net/samples/EchoServer/src/EchoServer.cpp#2 $
// $Id: //poco/1.2/Net/samples/EchoServer/src/EchoServer.cpp#1 $
//
// This sample demonstrates the SocketReactor and SocketAcceptor classes.
//
@@ -32,34 +32,34 @@
//
#include "Net/SocketReactor.h"
#include "Net/SocketAcceptor.h"
#include "Net/SocketNotification.h"
#include "Net/StreamSocket.h"
#include "Net/ServerSocket.h"
#include "Foundation/Observer.h"
#include "Foundation/Exception.h"
#include "Foundation/Thread.h"
#include "Util/ServerApplication.h"
#include "Util/Option.h"
#include "Util/OptionSet.h"
#include "Util/HelpFormatter.h"
#include "Poco/Net/SocketReactor.h"
#include "Poco/Net/SocketAcceptor.h"
#include "Poco/Net/SocketNotification.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/Observer.h"
#include "Poco/Exception.h"
#include "Poco/Thread.h"
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include <iostream>
using Net::SocketReactor;
using Net::SocketAcceptor;
using Net::ReadableNotification;
using Net::ShutdownNotification;
using Net::ServerSocket;
using Net::StreamSocket;
using Foundation::Observer;
using Foundation::Thread;
using Util::ServerApplication;
using Util::Application;
using Util::Option;
using Util::OptionSet;
using Util::HelpFormatter;
using Poco::Net::SocketReactor;
using Poco::Net::SocketAcceptor;
using Poco::Net::ReadableNotification;
using Poco::Net::ShutdownNotification;
using Poco::Net::ServerSocket;
using Poco::Net::StreamSocket;
using Poco::Observer;
using Poco::Thread;
using Poco::Util::ServerApplication;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
class EchoServiceHandler
@@ -119,7 +119,7 @@ private:
};
class EchoServer: public Util::ServerApplication
class EchoServer: public Poco::Util::ServerApplication
/// The main application class.
///
/// This class handles command-line arguments and

View File

@@ -0,0 +1,10 @@
# This is a sample configuration file for HTTPFormServer
logging.loggers.root.channel.class = ConsoleChannel
logging.loggers.app.name = Application
logging.loggers.app.channel = c1
logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = [%p] %t
logging.channels.c1.class = ConsoleChannel
logging.channels.c1.formatter = f1
HTTPFormServer.port = 9980

View File

@@ -0,0 +1,8 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.2/Net/samples/HTTPFormServer/HTTPFormServer.vmsbuild#1 $
#
EXE=HTTPFormServer
HTTPFormServer
<SourceFilesHere>

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="HTTPFormServer"
ProjectGUID="{45A054E6-44EC-4943-809A-BA8B2A25DA21}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
OutputFile="bin/HTTPFormServerd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/HTTPFormServerd.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
OutputFile="bin/HTTPFormServer.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Configuration Files"
Filter="">
<File
RelativePath=".\HTTPFormServer.properties">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\HTTPFormServer.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="HTTPFormServer"
ProjectGUID="{5363487F-1F23-4F9E-B6A7-5471B0F2373F}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
OutputFile="bin/HTTPFormServerd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="bin/HTTPFormServerd.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true"
RuntimeLibrary="2"
BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
OutputFile="bin/HTTPFormServer.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Configuration Files"
>
<File
RelativePath=".\HTTPFormServer.properties"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\HTTPFormServer.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,17 @@
#
# Makefile
#
# $Id: //poco/1.2/Net/samples/HTTPFormServer/Makefile#1 $
#
# Makefile for Poco HTTPFormServer
#
include $(POCO_BASE)/build/rules/global
objects = HTTPFormServer
target = HTTPFormServer
target_version = 1
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -0,0 +1,326 @@
//
// HTTPFormServer.cpp
//
// $Id: //poco/Main/Net/samples/HTTPFormServer/src/HTTPFormServer.cpp#5 $
//
// This sample demonstrates the HTTPServer and HTMLForm classes.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTMLForm.h"
#include "Poco/Net/PartHandler.h"
#include "Poco/Net/MessageHeader.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/CountingStream.h"
#include "Poco/NullStream.h"
#include "Poco/StreamCopier.h"
#include "Poco/Exception.h"
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include <iostream>
using Poco::Net::ServerSocket;
using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPRequestHandlerFactory;
using Poco::Net::HTTPServer;
using Poco::Net::HTTPServerRequest;
using Poco::Net::HTTPServerResponse;
using Poco::Net::HTTPServerParams;
using Poco::Net::MessageHeader;
using Poco::Net::HTMLForm;
using Poco::Net::NameValueCollection;
using Poco::Util::ServerApplication;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
using Poco::CountingInputStream;
using Poco::NullOutputStream;
using Poco::StreamCopier;
class MyPartHandler: public Poco::Net::PartHandler
{
public:
MyPartHandler():
_length(0)
{
}
void handlePart(const MessageHeader& header, std::istream& stream)
{
_type = header.get("Content-Type", "(unspecified)");
if (header.has("Content-Disposition"))
{
std::string disp;
NameValueCollection params;
MessageHeader::splitParameters(header["Content-Disposition"], disp, params);
_name = params.get("name", "(unnamed)");
_fileName = params.get("filename", "(unnamed)");
}
CountingInputStream istr(stream);
NullOutputStream ostr;
StreamCopier::copyStream(istr, ostr);
_length = istr.chars();
}
int length() const
{
return _length;
}
const std::string& name() const
{
return _name;
}
const std::string& fileName() const
{
return _fileName;
}
const std::string& contentType() const
{
return _type;
}
private:
int _length;
std::string _type;
std::string _name;
std::string _fileName;
};
class FormRequestHandler: public HTTPRequestHandler
/// Return a HTML document with the current date and time.
{
public:
FormRequestHandler()
{
}
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
{
Application& app = Application::instance();
app.logger().information("Request from " + request.clientAddress().toString());
MyPartHandler partHandler;
HTMLForm form(request, request.stream(), partHandler);
response.setChunkedTransferEncoding(true);
response.setContentType("text/html");
std::ostream& ostr = response.send();
ostr <<
"<html>\n"
"<head>\n"
"<title>POCO Form Server Sample</title>\n"
"</head>\n"
"<body>\n"
"<h1>POCO Form Server Sample</h1>\n"
"<h2>GET Form</h2>\n"
"<form method=\"GET\" action=\"/form\">\n"
"<input type=\"text\" name=\"text\" size=\"31\">\n"
"<input type=\"submit\" value=\"GET\">\n"
"</form>\n"
"<h2>POST Form</h2>\n"
"<form method=\"POST\" action=\"/form\">\n"
"<input type=\"text\" name=\"text\" size=\"31\">\n"
"<input type=\"submit\" value=\"POST\">\n"
"</form>\n"
"<h2>File Upload</h2>\n"
"<form method=\"POST\" action=\"/form\" enctype=\"multipart/form-data\">\n"
"<input type=\"file\" name=\"file\" size=\"31\"> \n"
"<input type=\"submit\" value=\"Upload\">\n"
"</form>\n";
ostr << "<h2>Request</h2><p>\n";
ostr << "Method: " << request.getMethod() << "<br>\n";
ostr << "URI: " << request.getURI() << "<br>\n";
NameValueCollection::ConstIterator it = request.begin();
NameValueCollection::ConstIterator end = request.end();
for (; it != end; ++it)
{
ostr << it->first << ": " << it->second << "<br>\n";
}
ostr << "</p>";
if (!form.empty())
{
ostr << "<h2>Form</h2><p>\n";
it = form.begin();
end = form.end();
for (; it != end; ++it)
{
ostr << it->first << ": " << it->second << "<br>\n";
}
ostr << "</p>";
}
if (!partHandler.name().empty())
{
ostr << "<h2>Upload</h2><p>\n";
ostr << "Name: " << partHandler.name() << "<br>\n";
ostr << "File Name: " << partHandler.fileName() << "<br>\n";
ostr << "Type: " << partHandler.contentType() << "<br>\n";
ostr << "Size: " << partHandler.length() << "<br>\n";
ostr << "</p>";
}
ostr << "</body>\n";
}
};
class FormRequestHandlerFactory: public HTTPRequestHandlerFactory
{
public:
FormRequestHandlerFactory()
{
}
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
{
return new FormRequestHandler;
}
};
class HTTPFormServer: public Poco::Util::ServerApplication
/// The main application class.
///
/// This class handles command-line arguments and
/// configuration files.
/// Start the HTTPFormServer executable with the help
/// option (/help on Windows, --help on Unix) for
/// the available command line options.
///
/// To use the sample configuration file (HTTPFormServer.properties),
/// copy the file to the directory where the HTTPFormServer executable
/// resides. If you start the debug version of the HTTPFormServer
/// (HTTPFormServerd[.exe]), you must also create a copy of the configuration
/// file named HTTPFormServerd.properties. In the configuration file, you
/// can specify the port on which the server is listening (default
/// 9980) and the format of the date/Form string sent back to the client.
///
/// To test the FormServer you can use any web browser (http://localhost:9980/).
{
public:
HTTPFormServer(): _helpRequested(false)
{
}
~HTTPFormServer()
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
ServerApplication::initialize(self);
}
void uninitialize()
{
ServerApplication::uninitialize();
}
void defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false));
}
void handleOption(const std::string& name, const std::string& value)
{
ServerApplication::handleOption(name, value);
if (name == "help")
_helpRequested = true;
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A web server that shows how to work with HTML forms.");
helpFormatter.format(std::cout);
}
int main(const std::vector<std::string>& args)
{
if (_helpRequested)
{
displayHelp();
}
else
{
unsigned short port = (unsigned short) config().getInt("HTTPFormServer.port", 9980);
// set-up a server socket
ServerSocket svs(port);
// set-up a HTTPServer instance
HTTPServer srv(new FormRequestHandlerFactory, svs, new HTTPServerParams);
// start the HTTPServer
srv.start();
// wait for CTRL-C or kill
waitForTerminationRequest();
// Stop the HTTPServer
srv.stop();
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
};
int main(int argc, char** argv)
{
HTTPFormServer app;
return app.run(argc, argv);
}

View File

@@ -0,0 +1,7 @@
#
# HTTPLoadTest.vmsbuild
#
# $Id: //poco/1.2/Net/samples/HTTPLoadTest/HTTPLoadTest.vmsbuild#1 $
#
EXE=HTTPLoadTest
HTTPLoadTest

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="HTTPLoadTest"
ProjectGUID="{455C9515-4914-49B6-93FB-C37242A6C21C}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
OutputFile="bin/HTTPLoadTestd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/HTTPLoadTestd.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
OutputFile="bin/HTTPLoadTest.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\HTTPLoadTest.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="HTTPLoadTest"
ProjectGUID="{DC23240B-5266-4486-A141-B8D6F25F7676}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoNetd.lib PocoUtild.lib"
OutputFile="bin/HTTPLoadTestd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="bin/HTTPLoadTestd.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Net\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true"
RuntimeLibrary="2"
BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoNet.lib PocoUtil.lib"
OutputFile="bin/HTTPLoadTest.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\HTTPLoadTest.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,17 @@
#
# Makefile
#
# $Id: //poco/1.2/Net/samples/HTTPLoadTest/Makefile#1 $
#
# Makefile for Poco HTTPLoadTest
#
include $(POCO_BASE)/build/rules/global
objects = HTTPLoadTest
target = HTTPLoadTest
target_version = 1
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -0,0 +1,388 @@
//
// HTTPLoadTest.cpp
//
// $Id: //poco/1.2/Net/samples/HTTPLoadTest/src/HTTPLoadTest.cpp#1 $
//
// This sample demonstrates the HTTPClientSession class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTTPCookie.h"
#include "Poco/Net/NameValueCollection.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/AutoPtr.h"
#include "Poco/Thread.h"
#include "Poco/Mutex.h"
#include "Poco/Runnable.h"
#include "Poco/Stopwatch.h"
#include "Poco/NumberParser.h"
#include "Poco/Exception.h"
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h"
#include <iostream>
using Poco::Net::HTTPClientSession;
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPMessage;
using Poco::Net::HTTPCookie;
using Poco::Net::NameValueCollection;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration;
using Poco::AutoPtr;
using Poco::Thread;
using Poco::FastMutex;
using Poco::Runnable;
using Poco::Stopwatch;
using Poco::NumberParser;
using Poco::Path;
using Poco::URI;
using Poco::Exception;
class HTTPClient : public Runnable
{
public:
HTTPClient(const URI& uri, int repetitions, bool cookies=false, bool verbose=false):
_uri(uri),
_cookies(cookies),
_verbose(verbose),
_repetitions(repetitions),
_usec(0),
_success(0)
{
_gRepetitions += _repetitions;
}
~HTTPClient()
{
}
void run()
{
Stopwatch sw;
std::vector<HTTPCookie> cookies;
for (int i = 0; i < _repetitions; ++i)
{
try
{
int usec = 0;
std::string path(_uri.getPathAndQuery());
if (path.empty()) path = "/";
HTTPClientSession session(_uri.getHost(), _uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
if (_cookies)
{
NameValueCollection nvc;
std::vector<HTTPCookie>::iterator it = cookies.begin();
for(; it != cookies.end(); ++it)
nvc.add((*it).getName(), (*it).getValue());
req.setCookies(nvc);
}
HTTPResponse res;
sw.restart();
session.sendRequest(req);
std::istream& rs = session.receiveResponse(res);
sw.stop();
_success += HTTPResponse::HTTP_OK == res.getStatus() ? 1 : 0;
if (_cookies) res.getCookies(cookies);
usec = sw.elapsed();
if (_verbose)
{
FastMutex::ScopedLock lock(_mutex);
std::cout
<< _uri.toString() << ' ' << res.getStatus() << ' ' << res.getReason()
<< ' ' << usec/1000.0 << "ms" << std::endl;
}
_usec += usec;
}
catch (Exception& exc)
{
FastMutex::ScopedLock lock(_mutex);
std::cerr << exc.displayText() << std::endl;
}
}
{
FastMutex::ScopedLock lock(_mutex);
_gSuccess += _success;
_gUsec += _usec;
}
if (_verbose)
printStats(_uri.toString(), _repetitions, _success, _usec);
}
static void printStats(std::string uri, int repetitions, int success, Poco::UInt64 usec);
static int totalAttempts();
static Poco::UInt64 totalMicroseconds();
static int totalSuccessCount();
private:
HTTPClient();
URI _uri;
bool _verbose;
bool _cookies;
int _repetitions;
Poco::UInt64 _usec;
int _success;
static int _gRepetitions;
static Poco::UInt64 _gUsec;
static int _gSuccess;
static FastMutex _mutex;
};
FastMutex HTTPClient::_mutex;
int HTTPClient::_gRepetitions;
Poco::UInt64 HTTPClient::_gUsec;
int HTTPClient::_gSuccess;
int HTTPClient::totalAttempts()
{
return _gRepetitions;
}
Poco::UInt64 HTTPClient::totalMicroseconds()
{
return _gUsec;
}
int HTTPClient::totalSuccessCount()
{
return _gSuccess;
}
void HTTPClient::printStats(std::string uri, int repetitions, int success, Poco::UInt64 usec)
{
FastMutex::ScopedLock lock(_mutex);
std::cout << std::endl << "--------------" << std::endl
<< "Statistics for " << uri << std::endl << "--------------"
<< std::endl
<< repetitions << " attempts, " << success << " succesful ("
<< ((float) success / (float) repetitions) * 100.0 << "%)" << std::endl
<< "Avg response time: " << ((float) usec / (float) repetitions) / 1000.0 << "ms, " << std::endl
<< "Avg requests/second handled: " << ((float) success /((float) usec / 1000000.0)) << std::endl
<< "Total time: " << (float) usec / 1000000.0 << std::endl;
}
class HTTPLoadTest: public Application
/// This sample demonstrates some of the features of the Poco::Util::Application class,
/// such as configuration file handling and command line arguments processing.
///
/// Try HTTPLoadTest --help (on Unix platforms) or HTTPLoadTest /help (elsewhere) for
/// more information.
{
public:
HTTPLoadTest():
_helpRequested(false),
_repetitions(1),
_threads(1),
_verbose(false),
_cookies(false)
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
// add your own initialization code here
}
void uninitialize()
{
// add your own uninitialization code here
Application::uninitialize();
}
void reinitialize(Application& self)
{
Application::reinitialize(self);
// add your own reinitialization code here
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false));
options.addOption(
Option("verbose", "v", "display messages on stdout")
.required(false)
.repeatable(false));
options.addOption(
Option("cookies", "c", "resend cookies")
.required(false)
.repeatable(false));
options.addOption(
Option("uri", "u", "HTTP URI")
.required(true)
.repeatable(false)
.argument("uri"));
options.addOption(
Option("repetitions", "r", "fetch repetitions")
.required(false)
.repeatable(false)
.argument("repetitions"));
options.addOption(
Option("threads", "t", "thread count")
.required(false)
.repeatable(false)
.argument("threads"));
}
void handleOption(const std::string& name, const std::string& value)
{
Application::handleOption(name, value);
if (name == "help")
_helpRequested = true;
else if (name == "verbose")
_verbose = true;
else if (name == "cookies")
_cookies = true;
else if (name == "uri")
_uri = value;
else if (name == "repetitions")
_repetitions = NumberParser::parse(value);
else if (name == "threads")
_threads = NumberParser::parse(value);
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample application that demonstrates some of the features of the Poco::Util::Application class.");
helpFormatter.format(std::cout);
}
void defineProperty(const std::string& def)
{
std::string name;
std::string value;
std::string::size_type pos = def.find('=');
if (pos != std::string::npos)
{
name.assign(def, 0, pos);
value.assign(def, pos + 1, def.length() - pos);
}
else name = def;
config().setString(name, value);
}
int main(const std::vector<std::string>& args)
{
if (_helpRequested)
{
displayHelp();
}
else
{
URI uri(_uri);
std::vector<Thread*> threads;
Stopwatch sw;
sw.start();
for (int i = 0; i < _threads; ++i)
{
Thread* pt = new Thread(_uri);
poco_check_ptr(pt);
threads.push_back(pt);
HTTPClient* pHTTPClient = new HTTPClient(uri, _repetitions, _cookies, _verbose);
poco_check_ptr(pHTTPClient);
threads.back()->start(*pHTTPClient);
}
std::vector<Thread*>::iterator it = threads.begin();
for(; it != threads.end(); ++it)
{
(*it)->join();
delete *it;
}
sw.stop();
HTTPClient::printStats(_uri, HTTPClient::totalAttempts(), HTTPClient::totalSuccessCount(), sw.elapsed());
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
bool _verbose;
bool _cookies;
std::string _uri;
int _repetitions;
int _threads;
};
int main(int argc, char** argv)
{
AutoPtr<HTTPLoadTest> pApp = new HTTPLoadTest;
try
{
pApp->init(argc, argv);
}
catch (Poco::Exception& exc)
{
pApp->logger().log(exc);
return Application::EXIT_CONFIG;
}
return pApp->run();
}

View File

@@ -7,5 +7,7 @@ logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = [%p] %t
logging.channels.c1.class = ConsoleChannel
logging.channels.c1.formatter = f1
# HTTPTimeServer.format = %W, %e %b %y %H:%M:%S %Z
# HTTPTimeServer.port = 9980
HTTPTimeServer.format = %W, %e %b %y %H:%M:%S %Z
HTTPTimeServer.port = 9980
HTTPTimeServer.maxQueued = 100
HTTPTimeServer.maxThreads = 200

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/HTTPTimeServer/HTTPTimeServer.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/HTTPTimeServer/HTTPTimeServer.vmsbuild#1 $
#
EXE=HTTPTimeServer
HTTPTimeServer

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/HTTPTimeServer/Makefile#1 $
# $Id: //poco/1.2/Net/samples/HTTPTimeServer/Makefile#1 $
#
# Makefile for Poco HTTPTimeServer
#
@@ -12,6 +12,6 @@ objects = HTTPTimeServer
target = HTTPTimeServer
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
//
// TimeServer.cpp
// HTTPTimeServer.cpp
//
// $Id: //poco/1.1.0/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#2 $
// $Id: //poco/1.2/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#1 $
//
// This sample demonstrates the HTTPServer and related classes.
//
@@ -32,40 +32,42 @@
//
#include "Net/HTTPServer.h"
#include "Net/HTTPRequestHandler.h"
#include "Net/HTTPRequestHandlerFactory.h"
#include "Net/HTTPServerParams.h"
#include "Net/HTTPServerRequest.h"
#include "Net/HTTPServerResponse.h"
#include "Net/HTTPServerParams.h"
#include "Net/ServerSocket.h"
#include "Foundation/Timestamp.h"
#include "Foundation/DateTimeFormatter.h"
#include "Foundation/DateTimeFormat.h"
#include "Foundation/Exception.h"
#include "Util/ServerApplication.h"
#include "Util/Option.h"
#include "Util/OptionSet.h"
#include "Util/HelpFormatter.h"
#include "Poco/Net/HTTPServer.h"
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTTPServerParams.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/Timestamp.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/Exception.h"
#include "Poco/ThreadPool.h"
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include <iostream>
using Net::ServerSocket;
using Net::HTTPRequestHandler;
using Net::HTTPRequestHandlerFactory;
using Net::HTTPServer;
using Net::HTTPServerRequest;
using Net::HTTPServerResponse;
using Net::HTTPServerParams;
using Foundation::Timestamp;
using Foundation::DateTimeFormatter;
using Foundation::DateTimeFormat;
using Util::ServerApplication;
using Util::Application;
using Util::Option;
using Util::OptionSet;
using Util::HelpFormatter;
using Poco::Net::ServerSocket;
using Poco::Net::HTTPRequestHandler;
using Poco::Net::HTTPRequestHandlerFactory;
using Poco::Net::HTTPServer;
using Poco::Net::HTTPServerRequest;
using Poco::Net::HTTPServerResponse;
using Poco::Net::HTTPServerParams;
using Poco::Timestamp;
using Poco::DateTimeFormatter;
using Poco::DateTimeFormat;
using Poco::ThreadPool;
using Poco::Util::ServerApplication;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
class TimeRequestHandler: public HTTPRequestHandler
@@ -122,7 +124,7 @@ private:
};
class HTTPTimeServer: public Util::ServerApplication
class HTTPTimeServer: public Poco::Util::ServerApplication
/// The main application class.
///
/// This class handles command-line arguments and
@@ -200,11 +202,18 @@ protected:
// get parameters from configuration file
unsigned short port = (unsigned short) config().getInt("HTTPTimeServer.port", 9980);
std::string format(config().getString("HTTPTimeServer.format", DateTimeFormat::SORTABLE_FORMAT));
int maxQueued = config().getInt("HTTPTimeServer.maxQueued", 100);
int maxThreads = config().getInt("HTTPTimeServer.maxThreads", 16);
ThreadPool::defaultPool().addCapacity(maxThreads);
HTTPServerParams* pParams = new HTTPServerParams;
pParams->setMaxQueued(maxQueued);
pParams->setMaxThreads(maxThreads);
// set-up a server socket
ServerSocket svs(port);
// set-up a HTTPServer instance
HTTPServer srv(new TimeRequestHandlerFactory(format), svs, new HTTPServerParams);
HTTPServer srv(new TimeRequestHandlerFactory(format), svs, pParams);
// start the HTTPServer
srv.start();
// wait for CTRL-C or kill

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/Mail/Mail.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/Mail/Mail.vmsbuild#1 $
#
EXE=Mail
Mail

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/Mail/Makefile#1 $
# $Id: //poco/1.2/Net/samples/Mail/Makefile#1 $
#
# Makefile for Poco Mail
#
@@ -12,6 +12,6 @@ objects = Mail
target = Mail
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
//
// Mail.cpp
//
// $Id: //poco/1.1.0/Net/samples/Mail/src/Mail.cpp#2 $
// $Id: //poco/1.2/Net/samples/Mail/src/Mail.cpp#1 $
//
// This sample demonstrates the MailMessage and SMTPClientSession classes.
//
@@ -32,21 +32,21 @@
//
#include "Net/MailMessage.h"
#include "Net/MailRecipient.h"
#include "Net/SMTPClientSession.h"
#include "Net/StringPartSource.h"
#include "Foundation/Path.h"
#include "Foundation/Exception.h"
#include "Poco/Net/MailMessage.h"
#include "Poco/Net/MailRecipient.h"
#include "Poco/Net/SMTPClientSession.h"
#include "Poco/Net/StringPartSource.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
#include <iostream>
using Net::MailMessage;
using Net::MailRecipient;
using Net::SMTPClientSession;
using Net::StringPartSource;
using Foundation::Path;
using Foundation::Exception;
using Poco::Net::MailMessage;
using Poco::Net::MailRecipient;
using Poco::Net::SMTPClientSession;
using Poco::Net::StringPartSource;
using Poco::Path;
using Poco::Exception;
const unsigned char PocoLogo[] =

View File

@@ -1,12 +1,14 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/Makefile#1 $
# $Id: //poco/1.2/Net/samples/Makefile#1 $
#
# Makefile for Poco Net Samples
#
.DEFAULT all:
.PHONY: projects
clean all: projects
projects:
$(MAKE) -C dict $(MAKECMDGOALS)
$(MAKE) -C TimeServer $(MAKECMDGOALS)
$(MAKE) -C httpget $(MAKECMDGOALS)

17
Net/samples/Ping/Makefile Normal file
View File

@@ -0,0 +1,17 @@
#
# Makefile
#
# $Id: //poco/1.2/Net/samples/Ping/Makefile#1 $
#
# Makefile for Poco ping
#
include $(POCO_BASE)/build/rules/global
objects = Ping
target = Ping
target_version = 1
target_libs = PocoFoundation PocoXML PocoUtil PocoNet
include $(POCO_BASE)/build/rules/exec

View File

@@ -0,0 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.2/Net/samples/Ping/Ping.vmsbuild#1 $
#
EXE=Ping
Ping

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Ping"
ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib PocoNetd.lib"
OutputFile="bin/Pingd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/Pingd.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib PocoNet.lib"
OutputFile="bin/Ping.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Configuration Files"
Filter="">
<File
RelativePath=".\Ping.properties">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\Ping.cpp">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="Ping"
ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib PocoNetd.lib"
OutputFile="bin/Pingd.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="bin/Pingd.pdb"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include;..\..\..\Net\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true"
RuntimeLibrary="2"
BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib PocoNet.lib"
OutputFile="bin/Ping.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Configuration Files"
>
<File
RelativePath=".\ping.properties"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Ping.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,8 @@
# This is a sample configuration file.
logging.loggers.root.channel.class = ConsoleChannel
logging.loggers.app.name = Application
logging.loggers.app.channel = c1
logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = %t
logging.channels.c1.class = ConsoleChannel
logging.channels.c1.formatter = f1

View File

@@ -0,0 +1,219 @@
//
// Ping.cpp
//
// $Id: //poco/1.2/Net/samples/Ping/src/Ping.cpp#1 $
//
// This sample demonstrates the Application class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Net/ICMPSocket.h"
#include "Poco/Net/ICMPClient.h"
#include "Poco/Net/IPAddress.h"
#include "Poco/Net/ICMPEventArgs.h"
#include "Poco/AutoPtr.h"
#include "Poco/NumberParser.h"
#include "Poco/Delegate.h"
#include <iostream>
#include <sstream>
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration;
using Poco::Net::ICMPSocket;
using Poco::Net::ICMPClient;
using Poco::Net::IPAddress;
using Poco::Net::ICMPEventArgs;
using Poco::AutoPtr;
using Poco::NumberParser;
using Poco::Delegate;
class Ping: public Application
/// This sample demonstrates the Poco::Net::ICMPClient in conjunction with
/// Poco Foundation C#-like events functionality.
///
/// Try Ping --help (on Unix platforms) or Ping /help (elsewhere) for
/// more information.
{
public:
Ping():
_helpRequested(false),
_icmpClient(IPAddress::IPv4),
_repetitions(4),
_target("localhost")
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
_icmpClient.pingBegin += Delegate<Ping, ICMPEventArgs>(this, &Ping::onBegin);
_icmpClient.pingReply += Delegate<Ping, ICMPEventArgs>(this, &Ping::onReply);
_icmpClient.pingError += Delegate<Ping, ICMPEventArgs>(this, &Ping::onError);
_icmpClient.pingEnd += Delegate<Ping, ICMPEventArgs>(this, &Ping::onEnd);
}
void uninitialize()
{
_icmpClient.pingBegin -= Delegate<Ping, ICMPEventArgs>(this, &Ping::onBegin);
_icmpClient.pingReply -= Delegate<Ping, ICMPEventArgs>(this, &Ping::onReply);
_icmpClient.pingError -= Delegate<Ping, ICMPEventArgs>(this, &Ping::onError);
_icmpClient.pingEnd -= Delegate<Ping, ICMPEventArgs>(this, &Ping::onEnd);
Application::uninitialize();
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false));
options.addOption(
Option("repetitions", "r", "define the number of repetitions")
.required(false)
.repeatable(false)
.argument("repetitions"));
options.addOption(
Option("target", "t", "define the target address")
.required(false)
.repeatable(false)
.argument("target"));
}
void handleOption(const std::string& name, const std::string& value)
{
Application::handleOption(name, value);
if (name == "help")
_helpRequested = true;
else if (name == "repetitions")
_repetitions = NumberParser::parse(value);
else if (name == "target")
_target = value;
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader(
"A sample application that demonstrates the functionality of the "
"Poco::Net::ICMPClient class in conjunction with Poco::Events package functionality.");
helpFormatter.format(std::cout);
}
int main(const std::vector<std::string>& args)
{
if (_helpRequested)
displayHelp();
else
_icmpClient.ping(_target, _repetitions);
return Application::EXIT_OK;
}
void onBegin(const void* pSender, ICMPEventArgs& args)
{
std::ostringstream os;
os << "Pinging " << args.hostName() << " [" << args.hostAddress() << "] with " << args.dataSize() << " bytes of data:"
<< std::endl << "---------------------------------------------" << std::endl;
logger().information(os.str());
}
void onReply(const void* pSender, ICMPEventArgs& args)
{
std::ostringstream os;
os << "Reply from " << args.hostAddress()
<< " bytes=" << args.dataSize()
<< " time=" << args.replyTime() << "ms"
<< " TTL=" << args.ttl();
logger().information(os.str());
}
void onError(const void* pSender, ICMPEventArgs& args)
{
std::ostringstream os;
os << args.error();
logger().information(os.str());
}
void onEnd(const void* pSender, ICMPEventArgs& args)
{
std::ostringstream os;
os << std::endl << "--- Ping statistics for " << args.hostName() << " ---"
<< std::endl << "Packets: Sent=" << args.sent() << ", Received=" << args.received()
<< " Lost=" << args.repetitions() - args.received() << " (" << 100.0 - args.percent() << "% loss),"
<< std::endl << "Approximate round trip times in milliseconds: " << std::endl
<< "Minimum=" << args.minRTT() << "ms, Maximum=" << args.maxRTT()
<< "ms, Average=" << args.avgRTT() << "ms"
<< std::endl << "------------------------------------------";
logger().information(os.str());
}
private:
bool _helpRequested;
ICMPClient _icmpClient;
int _repetitions;
std::string _target;
};
int main(int argc, char** argv)
{
AutoPtr<Ping> pApp = new Ping;
try
{
pApp->init(argc, argv);
}
catch (Poco::Exception& exc)
{
pApp->logger().log(exc);
return Application::EXIT_CONFIG;
}
return pApp->run();
}

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/TimeServer/Makefile#1 $
# $Id: //poco/1.2/Net/samples/TimeServer/Makefile#1 $
#
# Makefile for Poco TimeServer
#
@@ -12,6 +12,6 @@ objects = TimeServer
target = TimeServer
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/TimeServer/TimeServer.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/TimeServer/TimeServer.vmsbuild#1 $
#
EXE=TimeServer
TimeServer

View File

@@ -1,7 +1,7 @@
//
// TimeServer.cpp
//
// $Id: //poco/1.1.0/Net/samples/TimeServer/src/TimeServer.cpp#2 $
// $Id: //poco/1.2/Net/samples/TimeServer/src/TimeServer.cpp#1 $
//
// This sample demonstrates the TCPServer and ServerSocket classes.
//
@@ -32,36 +32,36 @@
//
#include "Net/TCPServer.h"
#include "Net/TCPServerConnection.h"
#include "Net/TCPServerConnectionFactory.h"
#include "Net/TCPServerParams.h"
#include "Net/StreamSocket.h"
#include "Net/ServerSocket.h"
#include "Foundation/Timestamp.h"
#include "Foundation/DateTimeFormatter.h"
#include "Foundation/DateTimeFormat.h"
#include "Foundation/Exception.h"
#include "Util/ServerApplication.h"
#include "Util/Option.h"
#include "Util/OptionSet.h"
#include "Util/HelpFormatter.h"
#include "Poco/Net/TCPServer.h"
#include "Poco/Net/TCPServerConnection.h"
#include "Poco/Net/TCPServerConnectionFactory.h"
#include "Poco/Net/TCPServerParams.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/Timestamp.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/Exception.h"
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include <iostream>
using Net::ServerSocket;
using Net::StreamSocket;
using Net::TCPServerConnection;
using Net::TCPServerConnectionFactory;
using Net::TCPServer;
using Foundation::Timestamp;
using Foundation::DateTimeFormatter;
using Foundation::DateTimeFormat;
using Util::ServerApplication;
using Util::Application;
using Util::Option;
using Util::OptionSet;
using Util::HelpFormatter;
using Poco::Net::ServerSocket;
using Poco::Net::StreamSocket;
using Poco::Net::TCPServerConnection;
using Poco::Net::TCPServerConnectionFactory;
using Poco::Net::TCPServer;
using Poco::Timestamp;
using Poco::DateTimeFormatter;
using Poco::DateTimeFormat;
using Poco::Util::ServerApplication;
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
class TimeServerConnection: public TCPServerConnection
@@ -87,7 +87,7 @@ public:
dt.append("\r\n");
socket().sendBytes(dt.data(), (int) dt.length());
}
catch (Foundation::Exception& exc)
catch (Poco::Exception& exc)
{
app.logger().log(exc);
}
@@ -117,7 +117,7 @@ private:
};
class TimeServer: public Util::ServerApplication
class TimeServer: public Poco::Util::ServerApplication
/// The main application class.
///
/// This class handles command-line arguments and

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/dict/Makefile#1 $
# $Id: //poco/1.2/Net/samples/dict/Makefile#1 $
#
# Makefile for Poco dict
#
@@ -12,6 +12,6 @@ objects = dict
target = dict
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/dict/dict.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/dict/dict.vmsbuild#1 $
#
EXE=dict
dict

View File

@@ -1,7 +1,7 @@
//
// dict.cpp
//
// $Id: //poco/1.1.0/Net/samples/dict/src/dict.cpp#2 $
// $Id: //poco/1.2/Net/samples/dict/src/dict.cpp#1 $
//
// This sample demonstrates the StreamSocket and SocketStream classes.
//
@@ -32,21 +32,21 @@
//
#include "Net/StreamSocket.h"
#include "Net/SocketStream.h"
#include "Net/SocketAddress.h"
#include "Foundation/StreamCopier.h"
#include "Foundation/Path.h"
#include "Foundation/Exception.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketStream.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
#include <iostream>
using Net::StreamSocket;
using Net::SocketStream;
using Net::SocketAddress;
using Foundation::StreamCopier;
using Foundation::Path;
using Foundation::Exception;
using Poco::Net::StreamSocket;
using Poco::Net::SocketStream;
using Poco::Net::SocketAddress;
using Poco::StreamCopier;
using Poco::Path;
using Poco::Exception;
int main(int argc, char** argv)

View File

@@ -12,6 +12,6 @@ objects = download
target = download
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
//
// download.cpp
//
// $Id: //poco/1.1.0/Net/samples/download/src/download.cpp#2 $
// $Id: //poco/1.2/Net/samples/download/src/download.cpp#1 $
//
// This sample demonstrates the URIStreamOpener class.
//
@@ -32,24 +32,24 @@
//
#include "Foundation/URIStreamOpener.h"
#include "Foundation/StreamCopier.h"
#include "Foundation/Path.h"
#include "Foundation/URI.h"
#include "Foundation/Exception.h"
#include "Net/HTTPStreamFactory.h"
#include "Net/FTPStreamFactory.h"
#include "Poco/URIStreamOpener.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/Exception.h"
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/FTPStreamFactory.h"
#include <memory>
#include <iostream>
using Foundation::URIStreamOpener;
using Foundation::StreamCopier;
using Foundation::Path;
using Foundation::URI;
using Foundation::Exception;
using Net::HTTPStreamFactory;
using Net::FTPStreamFactory;
using Poco::URIStreamOpener;
using Poco::StreamCopier;
using Poco::Path;
using Poco::URI;
using Poco::Exception;
using Poco::Net::HTTPStreamFactory;
using Poco::Net::FTPStreamFactory;
int main(int argc, char** argv)

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.1.0/Net/samples/httpget/Makefile#1 $
# $Id: //poco/1.2/Net/samples/httpget/Makefile#1 $
#
# Makefile for Poco httpget
#
@@ -12,6 +12,6 @@ objects = httpget
target = httpget
target_version = 1
target_libs = PocoFoundation PocoXML PocoNet PocoUtil
target_libs = PocoUtil PocoNet PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec

View File

@@ -1,7 +1,7 @@
#
# sample.vmsbuild
#
# $Id: //poco/1.1.0/Net/samples/httpget/httpget.vmsbuild#1 $
# $Id: //poco/1.2/Net/samples/httpget/httpget.vmsbuild#1 $
#
EXE=httpget
httpget

View File

@@ -1,7 +1,7 @@
//
// httpget.cpp
//
// $Id: //poco/1.1.0/Net/samples/httpget/src/httpget.cpp#2 $
// $Id: //poco/1.2/Net/samples/httpget/src/httpget.cpp#1 $
//
// This sample demonstrates the HTTPClientSession class.
//
@@ -32,24 +32,24 @@
//
#include "Net/HTTPClientSession.h"
#include "Net/HTTPRequest.h"
#include "Net/HTTPResponse.h"
#include "Foundation/StreamCopier.h"
#include "Foundation/Path.h"
#include "Foundation/URI.h"
#include "Foundation/Exception.h"
#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/Exception.h"
#include <iostream>
using Net::HTTPClientSession;
using Net::HTTPRequest;
using Net::HTTPResponse;
using Net::HTTPMessage;
using Foundation::StreamCopier;
using Foundation::Path;
using Foundation::URI;
using Foundation::Exception;
using Poco::Net::HTTPClientSession;
using Poco::Net::HTTPRequest;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPMessage;
using Poco::StreamCopier;
using Poco::Path;
using Poco::URI;
using Poco::Exception;
int main(int argc, char** argv)

View File

@@ -27,6 +27,18 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mail", "Mail\Mail_vs71.vcpr
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPLoadTest", "HTTPLoadTest\HTTPLoadTest_vs71.vcproj", "{455C9515-4914-49B6-93FB-C37242A6C21C}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ping", "Ping\Ping_vs71.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPFormServer", "HTTPFormServer\HTTPFormServer_vs71.vcproj", "{45A054E6-44EC-4943-809A-BA8B2A25DA21}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
debug_shared = debug_shared
@@ -61,6 +73,18 @@ Global
{1B776CF5-3889-48D1-A58B-694D06FBD632}.debug_shared.Build.0 = debug_shared|Win32
{1B776CF5-3889-48D1-A58B-694D06FBD632}.release_shared.ActiveCfg = release_shared|Win32
{1B776CF5-3889-48D1-A58B-694D06FBD632}.release_shared.Build.0 = release_shared|Win32
{455C9515-4914-49B6-93FB-C37242A6C21C}.debug_shared.ActiveCfg = debug_shared|Win32
{455C9515-4914-49B6-93FB-C37242A6C21C}.debug_shared.Build.0 = debug_shared|Win32
{455C9515-4914-49B6-93FB-C37242A6C21C}.release_shared.ActiveCfg = release_shared|Win32
{455C9515-4914-49B6-93FB-C37242A6C21C}.release_shared.Build.0 = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.ActiveCfg = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.Build.0 = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.ActiveCfg = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.Build.0 = release_shared|Win32
{45A054E6-44EC-4943-809A-BA8B2A25DA21}.debug_shared.ActiveCfg = debug_shared|Win32
{45A054E6-44EC-4943-809A-BA8B2A25DA21}.debug_shared.Build.0 = debug_shared|Win32
{45A054E6-44EC-4943-809A-BA8B2A25DA21}.release_shared.ActiveCfg = release_shared|Win32
{45A054E6-44EC-4943-809A-BA8B2A25DA21}.release_shared.Build.0 = release_shared|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@@ -14,6 +14,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EchoServer", "EchoServer\Ec
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mail", "Mail\Mail_vs80.vcproj", "{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPLoadTest", "HTTPLoadTest\HTTPLoadTest_vs80.vcproj", "{DC23240B-5266-4486-A141-B8D6F25F7676}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ping", "Ping\Ping_vs80.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HTTPFormServer", "HTTPFormServer\HTTPFormServer_vs80.vcproj", "{5363487F-1F23-4F9E-B6A7-5471B0F2373F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32
@@ -48,6 +54,18 @@ Global
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.debug_shared|Win32.Build.0 = debug_shared|Win32
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_shared|Win32.ActiveCfg = release_shared|Win32
{D6C4B3D4-2026-4A33-B4DA-ABE8FF2EE0B8}.release_shared|Win32.Build.0 = release_shared|Win32
{DC23240B-5266-4486-A141-B8D6F25F7676}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{DC23240B-5266-4486-A141-B8D6F25F7676}.debug_shared|Win32.Build.0 = debug_shared|Win32
{DC23240B-5266-4486-A141-B8D6F25F7676}.release_shared|Win32.ActiveCfg = release_shared|Win32
{DC23240B-5266-4486-A141-B8D6F25F7676}.release_shared|Win32.Build.0 = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.Build.0 = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.ActiveCfg = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.Build.0 = release_shared|Win32
{5363487F-1F23-4F9E-B6A7-5471B0F2373F}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{5363487F-1F23-4F9E-B6A7-5471B0F2373F}.debug_shared|Win32.Build.0 = debug_shared|Win32
{5363487F-1F23-4F9E-B6A7-5471B0F2373F}.release_shared|Win32.ActiveCfg = release_shared|Win32
{5363487F-1F23-4F9E-B6A7-5471B0F2373F}.release_shared|Win32.Build.0 = release_shared|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE