# LaozuCppTcpStream **Repository Path**: MyDearest35/laozu-cpp-tcp-stream ## Basic Information - **Project Name**: LaozuCppTcpStream - **Description**: 克隆他人的TcpStream - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-10 - **Last Updated**: 2025-05-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # tstream : 标准C++流的TCP实现 1. 克隆他人的仓库 1. GitHub - luzhlon/tstream https://github.com/luzhlon/tstream 2. 百度知乎 C++流的streambuf详解及TCP流的实现 https://zhuanlan.zhihu.com/p/27072803 ## 客户端 ```cpp #include tstream ts("127.0.0.1", 2048); if (ts) { string line; ts >> line; // 接收数据 ts << line << endl; // 发送数据 } else { // 连接失败,处理错误 } ``` ## 服务端 ```cpp #include tstream::server server("127.0.0.1", 2048); auto ts = server.accept(); if (ts) { string line; ts << "Hello" << endl; ts >> line; // ... } ``` ## Features * 跨平台: Windows/Linux/Mac * 小巧: 只有一个头文件 * 简洁: 采用了部分C++11特性,支持移动语义