UINT CSockettestDlg::ComputeThreadProc(LPVOID pParam)
{
    struct sockaddr_in remote_addr;
int sin_size=sizeof(struct sockaddr_in);
char buf[1024]={0};
int ret;
CSockettestDlg *pDlg = (CSockettestDlg *)pParam;
//while(1)
//{
if((client_fd=accept(sockfd,(struct sockaddr *)&remote_addr,&sin_size))!=-1)
{
pDlg->SendMessage(WM_MY_MESSAGE);
//pDlg->MessageBox("Hello World!");
//pDlg->GetDlgItem(IDC_BUTTON1,GetSafeHwnd())->SetWindowText("断开");
capture=false;
}
// if(capture)
// break;
    if((ret=recv(client_fd,buf,sizeof(buf),0))==-1)

pDlg->MessageBox("Receive失败!");
m_messagerecv.Format("%s",buf);
pDlg->UpdateData(FALSE);
}以上是从线程   主线程为
WORD wVersionRequested;
WSADATA wsaData;
int err;
 
wVersionRequested = MAKEWORD( 1, 1 );
 
WSAStartup( wVersionRequested, &wsaData );
 
if ( LOBYTE( wsaData.wVersion ) != 1 ||HIBYTE( wsaData.wVersion ) != 1 ) 
{
WSACleanup( );
}
if((sockfd_client=socket(AF_INET,SOCK_STREAM,0))==-1)
MessageBox("socket创建错误!");

my_addr.sin_addr.S_un.S_addr=inet_addr(ip);
my_addr.sin_family=AF_INET;
my_addr.sin_port=htons(m_port);
if(connect(sockfd_client,(struct sockaddr *)&my_addr,sizeof(struct sockaddr))!=-1)
                {
GetDlgItem(IDC_BUTTON1)->SetWindowText("断开");
capture=false;
}
char temp[]="Hello World!";
if(send(sockfd_client,temp,strlen(temp),0)==-1)
MessageBox("Send 错误!");connect和accept均正确    但是运行崩溃  receive和send出错   不知道什么原因