CClientView::~CClientView()
{if(m_bInitialized)
WSACleanup();本文来自优,文~论^文·网原文请找腾讯752018766
closesocket(m_sock);
if(m_hListenThread)
::TerminateThread(m_hListenThread,0);
}
5.在菜单中添加"拨号"项:
void CClientView::OnDial()
{
// TODO: Add your command handler code here
count=5;
if(m_bInitialized)
{
AfxMessageBox("Already dialing");
return;
}
Cdial dial;
if(dial.DoModal()==
IDOK&&!dial.m_HostAddress.IsEmpty())
{
m_saSrvr.sin_family=AF_INET;
m_saSrvr.sin_addr.S_un.S_addr=htonl
(INADDR_ANY);
m_saSrvr.sin_addr.S_un.S_addr=inet_addr论文网http://www.youerw.com/
(dial.m_HostAddress);
m_saSrvr.sin_port=htons(5050);
int status;
WSADATA wsaData;
m_data[0]="initializing Windows Sockets DLL....";
if((status=WSAStartup(0x0101,&wsaData))==0)
{
m_data[0]+="Succeeded";
m_bInitialized=TRUE;
}
else
{
m_bInitialized=FALSE;
}
m_sock=socket(AF_INET,SOCK_DGRAM,0);
m_data[1]="Creating socket....";
if(m_sock==INVALID_SOCKET)
{
m_data[1]+="Failed";
}本文来自优,文~论^文·网原文请找腾讯752018766
m_data[1]+="Succeeded";
m_data[2]="Binding socket....";
sockaddr_in sa;
sa.sin_family=AF_INET;
sa.sin_addr.S_un.S_addr=htonl
(INADDR_ANY);
sa.sin_port=htons(0);
if(bind(m_sock,(PSOCKADDR)&sa,
sizeof(sa))==SOCKET_ERROR)
{
m_data[2]+="Failed";
closesocket(m_sock);
}
m_data[2]+="Succeeded";
m_data[3]="Creating listener thread....";
unsigned long idThread;
上一页 [1] [2] [3] [4] [5] [6] 下一页