c++问题,我在网上下了一个c++写的视频传输的程序,c/s模式,但是不知道程序具体的意思,各位帮帮我解释一
其中包括好几个部分,源文件有ListenSock.cpp,ServerCtrlSock.cpp,ServerPlus.cpp,ServerPlusDlg.cpp,Serv...
其中包括好几个部分,源文件有ListenSock.cpp,ServerCtrlSock.cpp,ServerPlus.cpp,ServerPlusDlg.cpp,ServerStreamSock.cpp,StdAfx.cpp。
其中的程序:ListenSock.cpp:
// ListenSock.cpp : implementation file
//
#include "stdafx.h"
#include "ServerPlus.h"
#include "ListenSock.h"
#include "ServerPlusDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListenSock
CListenSock::CListenSock()
{
}
CListenSock::~CListenSock()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CListenSock, CAsyncSocket)
//{{AFX_MSG_MAP(CListenSock)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CListenSock member functions
void CListenSock::OnAccept(int nErrorCode)
{
CServerPlusDlg* pDlg=(CServerPlusDlg*)::AfxGetMainWnd();
if (pDlg->m_ServerStreamSock.m_hSocket==INVALID_SOCKET && nErrorCode==0)
{
Accept(pDlg->m_ServerStreamSock);
pDlg->m_ServerStreamSock.AsyncSelect(FD_READ | FD_WRITE);
}
else if(pDlg->m_ServerCtrlSock==INVALID_SOCKET && nErrorCode==0)
{
Accept(pDlg->m_ServerCtrlSock);
pDlg->m_ServerCtrlSock.AsyncSelect(FD_READ | FD_WRITE|FD_CONNECT);
AfxMessageBox("User Connected,Begin transporting video image!");
//send the compressor's output format to the client as the decompressor's input format
SERVER_CTRL_MSG msg;
memset(&msg,0,sizeof(SERVER_CTRL_MSG));
strcpy(msg.strCommand,"Set Bitmap Info");
memcpy(msg.strContent,pDlg->m_pOutInfo,sizeof(BITMAPINFO));
msg.nContentUsedByte=sizeof(BITMAPINFO);
pDlg->m_ServerCtrlSock.Send(&msg,sizeof(SERVER_CTRL_MSG));
//send the compressor's COMPVARS struct to the client
memset(&msg,0,sizeof(SERVER_CTRL_MSG));
strcpy(msg.strCommand,"Set COMPVARS");
msg.nContentUsedByte=sizeof(COMPVARS);
memcpy(msg.strContent,&pDlg->m_CV,sizeof(COMPVARS));
pDlg->m_ServerCtrlSock.Send(&msg,sizeof(SERVER_CTRL_MSG));
afxDump<<pDlg->m_CV.fccType<<"\n";
pDlg->m_bConnect=TRUE;
}
// TODO: Add your specialized code here and/or call the base class
CAsyncSocket::OnAccept(nErrorCode);
}
就是不明白,请各位解释一下,好的我一定加分,谢谢...... 展开
其中的程序:ListenSock.cpp:
// ListenSock.cpp : implementation file
//
#include "stdafx.h"
#include "ServerPlus.h"
#include "ListenSock.h"
#include "ServerPlusDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListenSock
CListenSock::CListenSock()
{
}
CListenSock::~CListenSock()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CListenSock, CAsyncSocket)
//{{AFX_MSG_MAP(CListenSock)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CListenSock member functions
void CListenSock::OnAccept(int nErrorCode)
{
CServerPlusDlg* pDlg=(CServerPlusDlg*)::AfxGetMainWnd();
if (pDlg->m_ServerStreamSock.m_hSocket==INVALID_SOCKET && nErrorCode==0)
{
Accept(pDlg->m_ServerStreamSock);
pDlg->m_ServerStreamSock.AsyncSelect(FD_READ | FD_WRITE);
}
else if(pDlg->m_ServerCtrlSock==INVALID_SOCKET && nErrorCode==0)
{
Accept(pDlg->m_ServerCtrlSock);
pDlg->m_ServerCtrlSock.AsyncSelect(FD_READ | FD_WRITE|FD_CONNECT);
AfxMessageBox("User Connected,Begin transporting video image!");
//send the compressor's output format to the client as the decompressor's input format
SERVER_CTRL_MSG msg;
memset(&msg,0,sizeof(SERVER_CTRL_MSG));
strcpy(msg.strCommand,"Set Bitmap Info");
memcpy(msg.strContent,pDlg->m_pOutInfo,sizeof(BITMAPINFO));
msg.nContentUsedByte=sizeof(BITMAPINFO);
pDlg->m_ServerCtrlSock.Send(&msg,sizeof(SERVER_CTRL_MSG));
//send the compressor's COMPVARS struct to the client
memset(&msg,0,sizeof(SERVER_CTRL_MSG));
strcpy(msg.strCommand,"Set COMPVARS");
msg.nContentUsedByte=sizeof(COMPVARS);
memcpy(msg.strContent,&pDlg->m_CV,sizeof(COMPVARS));
pDlg->m_ServerCtrlSock.Send(&msg,sizeof(SERVER_CTRL_MSG));
afxDump<<pDlg->m_CV.fccType<<"\n";
pDlg->m_bConnect=TRUE;
}
// TODO: Add your specialized code here and/or call the base class
CAsyncSocket::OnAccept(nErrorCode);
}
就是不明白,请各位解释一下,好的我一定加分,谢谢...... 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询