Socketstream
An std::iostream derived C++ class for synchronous socket I/O.
Install / Use
/learn @Protovision/SocketstreamREADME
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
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
