资源简介
P2P聊天软件使用VC6开发,包括文字聊天和语音聊天功能,总之很强大,可以学习下

代码片段和文件信息
// LoginDlg.cpp : implementation file
//
#pragma comment(lib“ws2_32.lib“)
#include “stdafx.h“
#include “P2PClient.h“
#include “LoginDlg.h“
#include “windows.h“
#include “Exception.h“
#include
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
UserList ClientList;
SOCKET PrimaryUDP;
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog
CLoginDlg::CLoginDlg(CP2PClientDlg *MainDlgCWnd* pParent /*=NULL*/)
: CDialog(CLoginDlg::IDD pParent)
{
//{{AFX_DATA_INIT(CLoginDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pMainDlg = MainDlg;
IsLogin = false;
}
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLoginDlg)
DDX_Control(pDX IDC_USERNAME m_UserName);
DDX_Control(pDX IDC_SVRIP m_SvrIP);
DDX_Control(pDX IDC_PASSWORD m_PassWord);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLoginDlg CDialog)
//{{AFX_MSG_MAP(CLoginDlg)
ON_BN_CLICKED(IDC_BUTTON_CANCEL OnButtonCancel)
ON_BN_CLICKED(IDC_BUTTON_LOGIN OnBtnLogin)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_RECVDATAOnRecvData)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers
SOCKET mksock(int type)
{
SOCKET sock = socket(AF_INET type 0);
if (sock < 0)
{
AfxMessageBox(“套接字创建失败!“);
return -1;
}
return sock;
}
void BindSock(SOCKET sock)
{
sockaddr_in sin;
sin.sin_addr.S_un.S_addr = INADDR_ANY;
sin.sin_family = AF_INET;
sin.sin_port = 0;
if (bind(sock (struct sockaddr*)&sin sizeof(sin)) < 0)
{
closesocket(sock);
AfxMessageBox(“绑定失败!“);
return;
}
}
BOOL ConnectToServer(SOCKET sockchar *username char *serverip)
{
sockaddr_in remote;
remote.sin_addr.S_un.S_addr = inet_addr(serverip);
remote.sin_family = AF_INET;
remote.sin_port = htons(SERVER_PORT);
stMessage sendbuf;
sendbuf.iMessageType = LOGIN;
strncpy(sendbuf.message.loginmember.userName username 10);
sendto(sock (const char*)&sendbuf sizeof(sendbuf) 0 (const sockaddr*)&remotesizeof(remote));
int usercount;
int fromlen = sizeof(remote);
int iread = recvfrom(sock (char *)&usercount sizeof(int) 0 (sockaddr *)&remote &fromlen);
if(iread<=0)
{
AfxMessageBox(“服务器连接失败!\n“);
return false;
}
// 登录到服务端后,接收服务端发来的已经登录的用户的信息
for(int i = 0;i {
stUserListNode *node = new stUserListNode;
recvfrom(sock (char*)node sizeof(stUserListNode) 0 (sockaddr *)&remote &fromlen);
ClientList.push_back(node);
}
return true;
}
void CLoginDlg::OnButtonCancel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
BOOL CLoginDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 74177 2011-05-09 13:45 P2P聊天\P2PClient\Debug\LoginDlg.obj
文件 122929 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClient.exe
文件 274296 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClient.ilk
文件 21653 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClient.obj
文件 5630376 2011-05-09 13:46 P2P聊天\P2PClient\Debug\P2PClient.pch
文件 484352 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClient.pdb
文件 3400 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClient.res
文件 94642 2011-05-09 13:45 P2P聊天\P2PClient\Debug\P2PClientDlg.obj
文件 110663 2011-05-09 13:45 P2P聊天\P2PClient\Debug\StdAfx.obj
文件 15016 2011-05-09 13:45 P2P聊天\P2PClient\Debug\TalkDlg.obj
文件 176225 2011-05-09 13:45 P2P聊天\P2PClient\Debug\TalkDll.dll
文件 263168 2011-05-09 13:45 P2P聊天\P2PClient\Debug\vc60.idb
文件 413696 2011-05-09 13:45 P2P聊天\P2PClient\Debug\vc60.pdb
文件 1997 2011-05-09 13:45 P2P聊天\P2PClient\Exception.h
文件 7724 2011-05-09 13:45 P2P聊天\P2PClient\LoginDlg.cpp
文件 1708 2011-05-09 13:45 P2P聊天\P2PClient\LoginDlg.h
文件 22188 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.aps
文件 2315 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.clw
文件 2568 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.cpp
文件 4465 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.dsp
文件 541 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.dsw
文件 1387 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.h
文件 99328 2011-05-11 17:56 P2P聊天\P2PClient\P2PClient.ncb
文件 570880 2011-05-11 17:56 P2P聊天\P2PClient\P2PClient.opt
文件 252 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.plg
文件 6916 2011-05-09 13:45 P2P聊天\P2PClient\P2PClient.rc
文件 15483 2011-05-09 13:45 P2P聊天\P2PClient\P2PClientDlg.cpp
文件 2038 2011-05-09 13:45 P2P聊天\P2PClient\P2PClientDlg.h
文件 3633 2011-05-09 13:45 P2P聊天\P2PClient\ReadMe.txt
文件 1078 2011-05-09 13:45 P2P聊天\P2PClient\res\P2PClient.ico
............此处省略80个文件信息
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- 简单的C语言点对点聊天程序
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 文件传输和聊天程序(c语言实现)
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
评论
共有 条评论