www.gusucode.com > UDP语音通讯控件源码程序 > UDP语音通讯控件源码程序/AUDIOS/AUDIO/RecSocket.cpp

    // RecSocket.cpp : implementation file
//

#include "stdafx.h"
#include "RecSocket.h"
#include "head.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRecSocket

CRecSocket::CRecSocket(CWaveOut *pTemp)
{
	m_bIni = FALSE;
	g_pOut = pTemp;
	m_pFrame = (struct Frame *)m_cBuffer;
}

CRecSocket::~CRecSocket()
{

}


// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CRecSocket, CSocket)
	//{{AFX_MSG_MAP(CRecSocket)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// CRecSocket member functions

BOOL CRecSocket::Ini(UINT nPort)
{
	if (m_bIni)
		return FALSE;

	if (!Create (nPort/*TALK_REC_PORT*/,SOCK_DGRAM))
		return FALSE;
	m_bIni = TRUE;
	return TRUE;

}

void CRecSocket::OnReceive(int nErrorCode)
{
	// TODO: Add your specialized code here and/or call the base class
	m_iLen = sizeof(m_cBuffer);
	m_iLen = this->Receive (m_pFrame,m_iLen);
	m_sort.ReceiveData (g_pOut,(char *)m_pFrame,m_iLen);
	CSocket::OnReceive(nErrorCode);
}

BOOL CRecSocket::CloseSocket()
{
	if (!m_bIni)
		return FALSE;
	m_bIni = FALSE;
	CSocket::Close ();
	return TRUE;
}