网络电话,可参考,socket编程,简单实用
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-11 00:02 Phone(音频)
文件 5821 2001-07-18 01:17 Phone(音频)BvSocket.cpp
文件 1971 2001-07-18 01:17 Phone(音频)BvSocket.h
文件 17452 2013-04-30 01:51 Phone(音频)Compression.cpp
文件 2036 2013-04-29 17:31 Phone(音频)Compression.h
目录 0 2013-12-11 00:15 Phone(音频)Debug
文件 6876 2013-05-17 09:58 Phone(音频)DebugBuildLog.htm
文件 42008 2013-05-12 22:01 Phone(音频)DebugCompression.obj
文件 23098 2013-05-12 22:01 Phone(音频)DebugIPAddress.obj
文件 126976 2013-05-17 09:58 Phone(音频)DebugPhone.exe
文件 920 2013-05-12 22:01 Phone(音频)DebugPhone.exe.embed.manifest
文件 984 2013-05-12 22:01 Phone(音频)DebugPhone.exe.embed.manifest.res
文件 861 2013-05-17 09:58 Phone(音频)DebugPhone.exe.intermediate.manifest
文件 1393448 2013-05-17 09:58 Phone(音频)DebugPhone.ilk
文件 22723 2013-05-16 15:18 Phone(音频)DebugPhone.obj
文件 25296896 2013-05-12 22:01 Phone(音频)DebugPhone.pch
文件 3730432 2013-05-17 09:58 Phone(音频)DebugPhone.pdb
文件 3732 2013-05-12 22:01 Phone(音频)DebugPhone.res
文件 83353 2013-05-17 09:58 Phone(音频)DebugPhoneDlg.obj
文件 18927 2013-05-16 15:18 Phone(音频)DebugSoundIn.obj
文件 17815 2013-05-12 22:01 Phone(音频)DebugSoundOut.obj
文件 465339 2013-05-12 22:01 Phone(音频)DebugStdAfx.obj
文件 67 2013-05-17 09:58 Phone(音频)Debugmt.dep
文件 953344 2013-05-17 09:58 Phone(音频)Debugvc90.idb
文件 2011136 2013-05-17 09:58 Phone(音频)Debugvc90.pdb
文件 1672 2013-04-29 14:52 Phone(音频)IPAddress.cpp
文件 1324 2013-04-29 14:52 Phone(音频)IPAddress.h
文件 23812 2013-05-11 22:57 Phone(音频)Phone.aps
文件 1800 2001-07-18 01:17 Phone(音频)Phone.clw
文件 2049 2001-07-18 01:17 Phone(音频)Phone.cpp
文件 4791 2001-07-18 01:17 Phone(音频)Phone.dsp
............此处省略26个文件信息
// BvSocket.cpp: implementation of the CBvSocket class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “Phone.h“
#include “BvSocket.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#pragma comment(lib “wsock32“)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBvSocket::CBvSocket()
{
}
CBvSocket::~CBvSocket()
{
}
void CBvSocket::ReportWinsockErr(LPSTR lpszErrorMsg)
{
char chMsgBuffer[100];
wsprintf(chMsgBuffer “
Winsock error %d: %s
“ WSAGetLastError() lpszErrorMsg);
MessageBox(NULLchMsgBuffer AfxGetAppName() MB_OK|MB_IConstop);
return;
}
BOOL CBvSocket::Init(WSADATA* wsaData)
{
if (WSAStartup(WINSOCK_VERSIONwsaData))
{
MessageBeep(MB_IConstop);
MessageBox(NULL“Winsock could not be initialized!“ AfxGetAppName() MB_OK|MB_IConstop);
WSACleanup();
return(FALSE);
}
return TRUE;
}
BOOL CBvSocket::Clean()
{
int iErrorCode;
char chMsgBuffer[100];
if ((iErrorCode = WSACleanup()))
{
wsprintf(chMsgBuffer “Winsock error %d.“ iErrorCode);
MessageBeep(MB_IConstop);
MessageBox(NULL chMsgBuffer AfxGetAppName() MB_OK|MB_IConstop);
return FALSE;
}
return TRUE;
}
BOOL CBvSocket::GetHostName(char *name int namelen)
//determine if the local machine is on_line!
{
if (gethostname(name namelen))
{
ReportWinsockErr(“
Could not resolve local host!
Are you on-line?
“);
return FALSE;
}
return TRUE;
}
BOOL CBvSocket::Create()
//Create the default socket for general use!
{
m_hSocket=socket(PF_INET SOCK_STREAM 0);
if (m_hSocket == INVALID_SOCKET)
{
ReportWinsockErr(“Could not create server socket.“);
return FALSE;
}
return TRUE;
}
BOOL CBvSocket::Create(int af int type int protocol)
//you can create the socket using the socketthere is equal!
{
m_hSocket=socket(aftypeprotocol);
if (m_hSocket == INVALID_SOCKET)
{
ReportWinsockErr(“Could not create server socket.“);
return FALSE;
}
return TRUE;
}
void CBvSocket::SetAddrIn(const char FAR* ip unsigned short port)
//you can set you socket address using the doted string format.
{
m_addrSocket.sin_family=AF_INET;
m_addrSocket.sin_addr.S_un.S_addr=inet_addr(ip);
m_addrSocket.sin_port=htons(port);
}
void CBvSocket::SetAddrIn(unsigned short port)
//you can also let the windows to process the ipif your machine have
//more than one ip.
{
m_addrSocket.sin_family=AF_INET;
m_addrSocket.sin_addr.S_un.S_addr=INADDR_ANY;
m_addrSocket.sin_port=htons(port);
}
BOOL CBvSocket::Bind()
//if you have used SetAddrIn() create the socket addressyou can call
//this default bind function to name the unnamed socket address.
{
if (bind(m_hSocket(LPSOCKADDR)&m_addrSocke
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-11 00:02 Phone(音频)
文件 5821 2001-07-18 01:17 Phone(音频)BvSocket.cpp
文件 1971 2001-07-18 01:17 Phone(音频)BvSocket.h
文件 17452 2013-04-30 01:51 Phone(音频)Compression.cpp
文件 2036 2013-04-29 17:31 Phone(音频)Compression.h
目录 0 2013-12-11 00:15 Phone(音频)Debug
文件 6876 2013-05-17 09:58 Phone(音频)DebugBuildLog.htm
文件 42008 2013-05-12 22:01 Phone(音频)DebugCompression.obj
文件 23098 2013-05-12 22:01 Phone(音频)DebugIPAddress.obj
文件 126976 2013-05-17 09:58 Phone(音频)DebugPhone.exe
文件 920 2013-05-12 22:01 Phone(音频)DebugPhone.exe.em
文件 984 2013-05-12 22:01 Phone(音频)DebugPhone.exe.em
文件 861 2013-05-17 09:58 Phone(音频)DebugPhone.exe.intermediate.manifest
文件 1393448 2013-05-17 09:58 Phone(音频)DebugPhone.ilk
文件 22723 2013-05-16 15:18 Phone(音频)DebugPhone.obj
文件 25296896 2013-05-12 22:01 Phone(音频)DebugPhone.pch
文件 3730432 2013-05-17 09:58 Phone(音频)DebugPhone.pdb
文件 3732 2013-05-12 22:01 Phone(音频)DebugPhone.res
文件 83353 2013-05-17 09:58 Phone(音频)DebugPhoneDlg.obj
文件 18927 2013-05-16 15:18 Phone(音频)DebugSoundIn.obj
文件 17815 2013-05-12 22:01 Phone(音频)DebugSoundOut.obj
文件 465339 2013-05-12 22:01 Phone(音频)DebugStdAfx.obj
文件 67 2013-05-17 09:58 Phone(音频)Debugmt.dep
文件 953344 2013-05-17 09:58 Phone(音频)Debugvc90.idb
文件 2011136 2013-05-17 09:58 Phone(音频)Debugvc90.pdb
文件 1672 2013-04-29 14:52 Phone(音频)IPAddress.cpp
文件 1324 2013-04-29 14:52 Phone(音频)IPAddress.h
文件 23812 2013-05-11 22:57 Phone(音频)Phone.aps
文件 1800 2001-07-18 01:17 Phone(音频)Phone.clw
文件 2049 2001-07-18 01:17 Phone(音频)Phone.cpp
文件 4791 2001-07-18 01:17 Phone(音频)Phone.dsp
............此处省略26个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)