#include <boost/asio.hpp>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#define LENGTH 1000
using namespace std;
using namespace boost::asio;
int main()
{
int spliceNum = 0;
map<int, string> mapFile;
fstream file("D:\\work\\testdata_case012.sp", ios::in | ios::out | ios::binary);
if (!file.is_open())
{
cout << "Open file failure!" << endl;
}
while (!file.eof())
{
char buffer_splice[LENGTH] = { 0 };
file.read(buffer_splice, LENGTH);
string strbuffer_splice(buffer_splice);
mapFile.insert(pair<int, string>(spliceNum, buffer_splice));
spliceNum++;
}
file.close();
try
{
io_service io;
ip::tcp::endpoint ep(ip::tcp::v4(), 6688); //v4()返回v4版的tcp对象,
ip::tcp::acceptor acceptor(io, ep);
while (1)
{
ip::tcp::socket sock(io);
acceptor.accept(sock);
std::cout << "client:" << sock.remote_endpoint().address() << std::endl;
char str1[LENGTH + 16] = { 0 };
for (int i = 0; i <spliceNum+1; i++)
{
strcpy_s(str1, mapFile.at(i).c_str());
sock.write_some(buffer(str1));
}
}
}
catch (std::exception& e)
{
std::cout << e.what() << std::endl;
}
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
tongbus_tongbuc.rar (40个子文件)
tongbus_tongbuc
tclient
tclient.v12.suo 19KB
tclient
tclient.vcxproj 3KB
client.cpp 762B
tclient.vcxproj.filters 947B
Debug
vc120.pdb 1004KB
client.obj 1006KB
vc120.idb 3.61MB
tclient.tlog
CL.write.1.tlog 1KB
CL.read.1.tlog 175KB
cl.command.1.tlog 1KB
link.write.1.tlog 1KB
tclient.lastbuildstate 173B
link.command.1.tlog 2KB
link.read.1.tlog 6KB
tclient.log 2KB
tclient.sdf 104.19MB
Debug
tclient.exe 213KB
tclient.pdb 2.63MB
tclient.ilk 1.12MB
tclient.sln 967B
tongbu
tongbu.sdf 103.5MB
tongbu.sln 964B
tongbu.v12.suo 31KB
tongbu
tongbu.vcxproj.filters 947B
tongbu.vcxproj 3KB
server.cpp 1KB
Debug
vc120.pdb 1.04MB
server.obj 1.24MB
tongbu.log 2KB
vc120.idb 3.63MB
tongbu.tlog
CL.write.1.tlog 998B
CL.read.1.tlog 176KB
cl.command.1.tlog 1KB
link.write.1.tlog 946B
link.command.1.tlog 2KB
link.read.1.tlog 6KB
tongbu.lastbuildstate 172B
Debug
tongbu.pdb 3.07MB
tongbu.exe 247KB
tongbu.ilk 1.22MB
共 40 条
- 1
资源评论
gjj1215
- 粉丝: 2
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 杨辉三角(Pascal's Triangle)是一个在数学中非常著名的数列,它以一种特定的模式排列数字,内容以5种代码实例实现
- yolov5数据集:CT图像肾脏、结石检测(2类别,包含训练集、验证集)
- 电力102规约请求报文实录
- RTL8723 linux+安卓驱动 2020版本
- ISO 26262 道路车辆-功能安全-系统级产品开发
- 数据挖掘期末题 选择填空简答
- EKF在CTRV模型上的建模推导
- 用于:https://laoshifu.blog.csdn.net/article/details/138191428 多层创建
- 电力102规约(电能累计量的传输规约)培训
- 「常用」E9外部流程接口
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功