作者在 2010-07-01 09:48:42 发布以下内容
UINT ThreadProc(LPVOID pPara)
{
{
Info *fo;
fo = (Info*)pPara;
fo = (Info*)pPara;
int nSize = sizeof(fo-> server);
SOCKET s = accept(fo-> s, (sockaddr*) &fo-> server,&nSize);
char buffer[100];
ZeroMemory(buffer,100);
ZeroMemory(buffer,100);
recv(s, buffer,100,0);
AfxMessageBox(buffer);
AfxMessageBox(buffer);
return 0;
}
void CSockThreadDlg::OnButton1()
{
// TODO: Add your control notification handler code here
WSADATA wsa;
WSAStartup(MAKEWORD(2,2), &wsa);
WSAStartup(MAKEWORD(2,2), &wsa);
SOCKET saServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr( "172.29.90.96 ");
server.sin_port = htons(17777);
server.sin_family = AF_INET;
server.sin_addr.s_addr = inet_addr( "172.29.90.96 ");
server.sin_port = htons(17777);
int iResult = bind(saServer, (sockaddr*)&server,sizeof(server));
iResult = listen(saServer,5);
iResult = listen(saServer,5);
Info fo;
fo.s = saServer;
fo.server = server;
fo.s = saServer;
fo.server = server;
AfxBeginThread(ThreadProc,&fo);
}