UINT RecvFunc (LPVOID pParam)
{
Cstrings strIP;
Cstrings strPort;
DLG CSendFileDlg *=(CSendFileDlg *) pParam;
(DLG - & gt; GetDlgItem (IDC_BUTTON_RECEIVE)) - & gt; The EnableWindow (FALSE);//???
DLG - & gt; GetDlgItemText (IDC_IPADDRESS1, strIP);//????????
DLG - & gt; GetDlgItemText (IDC_PORT1 strPort);
DLG - & gt; CliSock. The Create ();
if(! DLG - & gt; CliSock. Connect ((LPCTSTR) strIP, 6000))//Connect
{
AfxMessageBox (" connection failed!" );
DLG - & gt; CliSock. Close ();
(DLG - & gt; GetDlgItem (IDC_BUTTON_RECEIVE)) - & gt; The EnableWindow (TRUE);
DLG=NULL;
TheRecv=NULL;
The return - 1;
}
SOCKET_STREAM_FILE_INFO StreamFileInfo1;
DLG - & gt; CliSock. The Receive (& amp; StreamFileInfo1, sizeof (SOCKET_STREAM_FILE_INFO));
CFile myFile.
MyFile. Open (StreamFileInfo1 szFileTitle, CFile: : modeCreate | CFile: : modeWrite | CFile: : typeBinary);//open or create file
AfxMessageBox (StreamFileInfo1 szFileTitle);
UINT nSize=0;
UINT nData=https://bbs.csdn.net/topics/0;
While (nSize & lt; StreamFileInfo1. NFileSizeLow)
{
//a byte * szBuf=new byte [1024].
Char * szBuf=new char [1024].
nData=https://bbs.csdn.net/topics/dlg-> cliSock. The Receive (szBuf, 1024);
MyFile. Write (szBuf, nData);//the contents to a file in the
NSize +=nData;
}
SetFileTime ((HANDLE) myFile. M_hFile, & amp; StreamFileInfo1 ftCreationTime,
& StreamFileInfo1 ftLastAccessTime, & amp; StreamFileInfo1. FtLastWriteTime);
MyFile. Close ();
SetFileAttributes (StreamFileInfo1 szFileTitle, StreamFileInfo1 dwFileAttributes);
DLG - & gt; CliSock. Close ();
AfxMessageBox (" the receiving end!" );
(DLG - & gt; GetDlgItem (IDC_BUTTON_RECEIVE)) - & gt; The EnableWindow (TRUE);
TheRecv=NULL;//??
DLG=NULL;
return 0;
}
CodePudding user response:
Don't know how many predecessors in the TCP SocketSend (many) send (less) send (wealth)
Has been so much illness recv (), recv (wealth)
Inside the trap!
http://bbs.csdn.net/topics/380167545
CodePudding user response:
It is recommended to use asynchronous