Skip to content

Commit

Permalink
chore(tcpclient): create sample
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Feb 27, 2024
1 parent 3235068 commit 6b3aab0
Show file tree
Hide file tree
Showing 10 changed files with 2,397 additions and 0 deletions.
215 changes: 215 additions & 0 deletions Net/samples/samples_vs170.sln

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Net/samples/tcpclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_executable(tcpclient src/tcpclient.cpp)
target_link_libraries(tcpclient PUBLIC Poco::Net)
15 changes: 15 additions & 0 deletions Net/samples/tcpclient/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Makefile
#
# Makefile for Poco tcpclient
#

include $(POCO_BASE)/build/rules/global

objects = tcpclient

target = tcpclient
target_version = 1
target_libs = PocoNet PocoFoundation

include $(POCO_BASE)/build/rules/exec
52 changes: 52 additions & 0 deletions Net/samples/tcpclient/src/tcpclient.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// tcpclient.cpp
//
// This sample demonstrates the StreamSocket and SocketStream classes.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//


#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
#include <iostream>


using Poco::Net::StreamSocket;
using Poco::Net::SocketAddress;
using Poco::Path;
using Poco::Exception;


int main(int argc, char** argv)
{
if (argc != 3)
{
Path p(argv[0]);
std::cout << "usage: " << p.getBaseName() << " IP:PORT DATA" << std::endl;
std::cout << " sends DATA to IP:PORT" << std::endl;
return 1;
}
std::string addr(argv[1]);
std::string str(argv[2]);

try
{
SocketAddress sa(addr);
StreamSocket sock(sa);

sock.sendBytes(str.data(), static_cast<int>(str.length()));
}
catch (Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
return 1;
}

return 0;
}
11 changes: 11 additions & 0 deletions Net/samples/tcpclient/tcpclient.progen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vc.project.guid = ${vc.project.guidFromName}
vc.project.name = ${vc.project.baseName}
vc.project.target = ${vc.project.name}
vc.project.type = executable
vc.project.pocobase = ..\\..\\..
vc.project.platforms = Win32
vc.project.configurations = debug_shared, release_shared, debug_static_mt, release_static_mt, debug_static_md, release_static_md
vc.project.prototype = ${vc.project.name}_vs90.vcproj
vc.project.compiler.include = ..\\..\\..\\Foundation\\include;..\\..\\..\\Net\\include
vc.project.compiler.additionalOptions = /Zc:__cplusplus
vc.project.linker.dependencies.Win32 = ws2_32.lib iphlpapi.lib
658 changes: 658 additions & 0 deletions Net/samples/tcpclient/tcpclient_vs160.vcxproj

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Net/samples/tcpclient/tcpclient_vs160.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{87c78361-daea-4728-a565-b99fa7bc529a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tcpclient.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
973 changes: 973 additions & 0 deletions Net/samples/tcpclient/tcpclient_vs170.vcxproj

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Net/samples/tcpclient/tcpclient_vs170.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{ad6a19f8-964e-4e1d-8f8f-54747985384c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tcpclient.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit 6b3aab0

Please sign in to comment.