vs2010 + MFC + UDP socket 聊天程序。


自己写的 vs2010 + MFC + UDP socket 聊天程序。界面简洁,运行后只会产生一个exe,在局域网内输入对方ip即可发送信息。在同一台主机上也可以同时开两个instance。
资源截图
代码片段和文件信息
#include “StdAfx.h“
#include “MySocket.h“

CMySocket::CMySocket(void)
{
pWnd = NULL;
}


CMySocket::~CMySocket(void)
{
}


void CMySocket::AttachCWnd(CWnd *pW)
{
    pWnd = pW;
}
 
void CMySocket::OnSend(int nErrorCode)
{
    if (pWnd)
    pWnd->SendMessage(SOCKET_EVENT (WPARAM)this SEND);
CSocket::OnSend(nErrorCode);
}

void CMySocket::OnReceive(int nErrorCode)
{
if (pWnd)
        pWnd->SendMessage(SOCKET_EVENT (WPARAM)this RETR);    

    // CSocket收到数据触发 OnReceive()函数
    CSocket::OnReceive(nErrorCode);
}

void CMySocket::OnClose(int nErrorCode)
{
    if (pWnd)
        pWnd->SendMessage(SOCKET_EVENT (WPARAM)this CLOSE);

     CSocket::OnClose(nErrorCode);
 }
 
void CMySocket::OnAccept(int nErrorCode)
{
    if (pWnd)
        pWnd->SendMessage(SOCKET_EVENT (WPARAM)this ACCEPT);

    CSocket::OnAccept(nErrorCode);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-10-12 18:38  姜勇_SimpleChat
     目录           0  2017-10-12 18:03  姜勇_SimpleChatDebug
     文件      228352  2017-10-12 18:03  姜勇_SimpleChatDebugSimpleChatServer.exe
     文件     1464248  2017-10-12 18:03  姜勇_SimpleChatDebugSimpleChatServer.ilk
     文件     6392832  2017-10-12 18:03  姜勇_SimpleChatDebugSimpleChatServer.pdb
     目录           0  2017-10-12 18:02  姜勇_SimpleChatSimpleChat
     目录           0  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebug
     文件      724420  2017-10-12 17:53  姜勇_SimpleChatSimpleChatDebugCL.read.1.tlog
     文件       20148  2017-10-12 17:53  姜勇_SimpleChatSimpleChatDebugCL.write.1.tlog
     文件       13733  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugMySocket.obj
     文件       68008  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugMySqlc.obj
     文件          82  2017-09-28 16:24  姜勇_SimpleChatSimpleChatDebugSimpleChat.lastbuildstate
     文件        1107  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebugSimpleChat.log
     文件       28008  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugSimpleChat.obj
     文件       70016  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugSimpleChat.res
     文件         853  2017-10-10 15:04  姜勇_SimpleChatSimpleChatDebugSimpleChat.vcxprojResolveAssemblyReference.cache
     文件      275670  2017-10-12 17:53  姜勇_SimpleChatSimpleChatDebugSimpleChatDlg.obj
     文件       11119  2017-09-29 13:25  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.Build.CppClean.log
     文件         915  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.exe.embed.manifest
     文件         980  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.exe.embed.manifest.res
     文件         640  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.exe.intermediate.manifest
     文件          77  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.lastbuildstate
     文件    39583744  2017-10-12 17:44  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.pch
     文件           0  2017-09-29 13:26  姜勇_SimpleChatSimpleChatDebugSimpleChatServer.write.1.tlog
     文件         222  2017-09-29 13:28  姜勇_SimpleChatSimpleChatDebugSimpleChatServer_manifest.rc
     文件       24926  2017-10-12 17:53  姜勇_SimpleChatSimpleChatDebugcl.command.1.tlog
     文件           2  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebuglink-cvtres.read.1.tlog
     文件           2  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebuglink-cvtres.write.1.tlog
     文件           2  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebuglink.2308-cvtres.read.1.tlog
     文件           2  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebuglink.2308-cvtres.write.1.tlog
     文件           2  2017-10-12 18:03  姜勇_SimpleChatSimpleChatDebuglink.2308.read.1.tlog
............此处省略162个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)