文件名称:client
- 所属分类:
- Internet/网络编程
- 资源属性:
- [Windows] [Visual.Net] [源码]
- 上传时间:
- 2016-12-12
- 文件大小:
- 28.7mb
- 下载次数:
- 0次
- 提 供 者:
- 陈
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
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
}-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
}
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
}-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
}
(系统自动生成,下载前可以参看下载内容)
下载文件列表
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