g_screenPort = m_clientPort;
udpSocket.InitSock();
UpdateData(FALSE);
CLIENT_TO_SERVER cmdTyep = UMS_LOGIN; //定义要发送的操作类型为登录
strcpy(account.id,m_username.GetBuffer(m_username.GetLength()));
strcpy(account.password,m_pass.GetBuffer(m_pass.GetLength()));
//将学生登录信息打包并发送
JOutStream jout;
jout << (uint8)cmdTyep;
jout.writebytes(&account,sizeof(ACCOUNT)); //打包学生信息
char buf[1024] = {0};
jout.getbuf(buf);
int len = jout.length();
udpSocket.SockSend(buf,len); //发送学生信息
CSysCfg::write_to_file(); //将学生信息写入配置文件
}
(3)服务器接收并查询数据库验证学生信息,并返回确认信息
int COperationLogin::Excute(JInStream jin, LPPER_IO_DATA pIoData, CMY_UdpIocpSrvDlg *p)
{
//解包学生信息数据包
jin.readbytes(account.id,13);
jin.readbytes(account.password,7);
CString m_account(account.id);
CString m_password(account.password);
//ADO连接Access数据库
JAdo db;
LONG ret = db.Connect(1,"Student.mdb","","","","");
if (ret == 0)
{
TRACE("DB connect success!");
}
else本文来自辣.文~论^文·网原文请找腾讯3249,114
{
strcpy(sendBuf,"DB connect failed!");
return -1;
}
bool alrLogin = FALSE;
map<int, CLIENT_INFO>::const_iterator map_it = client_map.begin();
while (map_it != client_map.end())
{
//遍历学生链容器,判断该学生是否已登录
if (strcmp(map_it->second.stuID,account.id) == 0)
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>
C++的多媒体屏幕广播教学系统设计 第15页下载如图片无法显示或论文不完整,请联系qq752018766