请问这样的程序流程是什么?
一下是一个socket文件传输的main主函数
程序是打开一个TCP服务,并监听,程序在“**********”处不再往下执行,
直到客户端请求的时候,再往下执行,请问他是如何停留在此处的呢?
没有道理啊。。。。
这个_tmain函数工作流程如何。。。。。?
using namespace std;
#define PORT 34000
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
AfxSocketInit(NULL);
CSocket sockSrvr;
sockSrvr.Create(PORT);
sockSrvr.Listen();
CSocket sockRecv;
sockSrvr.Accept(sockRecv);//*********停留在此处
CFile myFile;
myFile.Open("C:\\CLDMA.LOG", CFile::modeRead | CFile::typeBinary);
int myFileLength = myFile.GetLength();
sockRecv.Send(&myFileLength, 4);
byte* data = new byte[myFileLength];
myFile.Read(data, myFileLength);
sockRecv.Send(data, myFileLength);
myFile.Close();
delete data;
sockRecv.Close();
}
return nRetCode;
}