测试协同CS模式下的客户端操作通知时间 采用协议TCP
来源:互联网 发布:php sendmail 发邮件 编辑:程序博客网 时间:2024/06/07 08:49
方法1:抓取发送的数据包和接收的数据,获取时间
方法2:由发送者将自己的时间作为一项数据发送给接收者
方法3:采用日志,记录发送时间和接收时间
#pragma once#define WIN32_LEAN_AND_MEAN#include <Windows.h>#include<string>#include<fstream>#include<time.h>using namespace std;class LogHelper{public:LogHelper(void);void Init(BLL* pBLL);~LogHelper(void);//string actorstr;发送、接收;string opstr操作类型:删除、拖动、分割删除、效果、编辑void WriteLog(char* actor_str,char* op_str);private:CRITICAL_SECTION csLogWrite; //多线程BLL* pBLL;};
#include "LogHelper.h"LogHelper::LogHelper(void){}void LogHelper::Init(BLL* pBLL){InitializeCriticalSection(&csLogWrite); this->pBLL = pBLL;}LogHelper::~LogHelper(void){DeleteCriticalSection(&csLogWrite);}void LogHelper::WriteLog(char* actor_str,char* op_str){EnterCriticalSection(&csLogWrite);try{//获取当前日期time_t t = time(0);char tmp[64];strftime(tmp,sizeof(tmp),"%Y%m%d",localtime(&t));ofstream fout;char fileName[100];if(strcmp(pBLL->dirName,"")!=0)sprintf(fileName,"%s\\%s_%s.Log",pBLL->dirName,pBLL->myName,tmp); elsesprintf(fileName,"%s_%s.Log",pBLL->myName,tmp); fout.open(fileName,ios::app);if(fout.is_open()){SYSTEMTIME sys_time;GetLocalTime(&sys_time);char msg[100];sprintf(msg,"%4d/%02d/%02d %02d:%02d:%02d.%03d %s%s",sys_time.wYear,sys_time.wMonth,sys_time.wDay,sys_time.wHour,sys_time.wMinute,sys_time.wSecond,sys_time.wMilliseconds,actor_str,op_str); fout<<msg<<endl;fout.close();}}catch (exception &e){}finally{LeaveCriticalSection(&csLogWrite);}}
0 0
- 测试协同CS模式下的客户端操作通知时间 采用协议TCP
- CS模式下的客户端的注册登录查询
- 实现采用客户/服务器通信模式,基于TCP网络通信协议的多客户端简单应用
- cs模式下的自动更新
- (笔记)Linux下网络编程,采用TCP协议实现的C/S架构
- 目前网络时间采用的协议
- 实现采用客户/服务器通信模式,基于TCP网络通信协议的多客户端简单应用之案例分析
- (TCP模式下)客户端与服务器交互
- 基于TCP/IP协议的客户端应用程序
- 基于TCP协议的服务器/客户端程序
- 基于TCP协议的服务器/客户端程序
- 基于TCP协议的客户端/服务器
- 采用TCP协议的C/S架构实现API详解
- c++做服务器,java当客户端,采用 tcp协议之相互通信demo
- 如何实现C/S模式下客户机与服务器采用统一的时间
- linux下C语言编程日志(1):基于TCP协议的服务器/客户端程序
- Linux 网络编程实现TCP协议下的服务器客户端通信
- Windows下使用TCP协议变长交互客户端和服务器的数据传输
- hdoj 1205 吃糖果 【鸽巢原理】
- SQLite 数据库获取添加记录后自增长的ID
- Java中常用设计模式总结
- 排列组合公式和写法
- 着色页(Color pictures to the real picture)
- 测试协同CS模式下的客户端操作通知时间 采用协议TCP
- dwz 弹出框分页实现方法
- hdoj 2073 无限的路【数学】
- #342Div2-625D Babaei and Birthday Cake线段树优化DP
- 开发优化--老板优化
- POJ 3468 A Simple Problem with Integers(线段树)
- linux有效修改max open files/ulimit -n
- 对多线程下载文件的理解和使用ksoap2-android调用WebService的操作步骤
- Hadoop学习笔记:MapReduce框架详解