Description: Tcp_client
SOCKET sclient socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
if(sclient INVALID_SOCKET)
{
printf( invalid socket ! )
return
}
CEdit* pEdit (CEdit*)GetDlgItem(IDC_EDIT_PORT)
CString sPort
pEdit->GetWindowTextW(sPort) //获取端口字符串
int dPort _ttoi(sPort) //获取端口整形
DWORD dwIP
m_IP.GetAddress(dwIP) //获取ip
sockaddr_in serAddr
serAddr.sin_family AF_INET
serAddr.sin_port htons(dPort)
serAddr.sin_addr.S_un.S_addr htonl(dwIP)
//创建连接
if (connect(sclient, (sockaddr*)&serAddr, sizeof(serAddr)) SOCKET_ERROR)
{
closesocket(sclient)
AfxMessageBox(_T( connect error ! ))
printf( connect error ! )
return
}
To Search:
File list (Check if you may need any files):
ipch\client-cc4e64b3\client-c767fd4b.ipch
client.sdf
client.sln
client.suo
......\client.aps
......\client.cpp
......\client.h
......\client.rc
......\client.vcxproj
......\client.vcxproj.filters
......\client.vcxproj.user
......\clientDlg.cpp
......\clientDlg.h
......\Debug\client.Build.CppClean.log
......\.....\client.log
......\ReadMe.txt
......\res\client.ico
......\...\client.rc2
......\resource.h
......\stdafx.cpp
......\stdafx.h
......\targetver.h
ipch\client-cc4e64b3
client\Debug
......\res
Debug\data
ipch
client
Debug