SkillAgentSearch skills...

Socketstream

An std::iostream derived C++ class for synchronous socket I/O.

Install / Use

/learn @Protovision/Socketstream
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

socketstream is a header-only library for socket I/O.

The following classes are defined:

swoope::socketbuf:
	An std::streambuf derived class that implements a raw socket
	device.

swoope::socketstream: 
	An std::iostream derived class that implements high-level 
	stream input/output on a swoope::socketbuf.

socketstream works with POSIX and Windows. Compatible with C++03, move semantics enabled for C++11.

Author: Mark Swoope Date: July 2017

Compiling and running the examples:

If you are using the Visual C++ compiler, the commands:

cl /EHsc server_example.cc ws2_32.lib cl /EHsc client_example.cc ws2_32.lib

should compile the example programs when issued from a Developer Command Prompt for VS.

If you are using the MinGW compiler, then the commands would be:

g++ -D _WIN32 -o server_example.exe server_example.cc -lws2_32 g++ -D _WIN32 -o client_example.exe client_example.cc -lws2_32

For Linux and Mac, the commands are:

g++ -o server_example.exe server_example.cc g++ -o client_example.exe client_example.cc

(.exe extention is optional for Linux and Mac)

After compiling successfully, to test the programs first run:

server_example.exe 6789

in one terminal window, then run

client_example.exe localhost 6789

In another terminal window and begin entering lines of text into the client terminal window to see the server echo them back.

Related Skills

View on GitHub
GitHub Stars11
CategoryDevelopment
Updated1y ago
Forks3

Languages

C++

Security Score

80/100

Audited on Apr 1, 2025

No findings