Click to See Complete Forum and Search --> : How Can I Send File use CSocket In Thread Mode


May 18th, 1999, 03:13 AM
Hello EveryBody:
I have a Promplem To Write a Socketprogram.

Program like this is right:

class clientsock:public CSocket
{
...
}

void clientsock::OnReceive(int nErrorCode)
{
if(nErrorCode==0)
{
....
CFile f11("c:\\a33.exe",CFile::modeRead);
while(f11.Read(by,1024)>0)
{
Send(by,1024);
}
f11.Close();
}
}
//*************************************************************
But I want to Send file in CWinThread Mode,Program like this is Error!!!

class mythread:public CWinThread
{
...
}

mythread::Ininstance()
{
CFile f11("c:\\a33.exe",CFile::modeRead);
while(f11.Read(by,1024)>0)
{
Send(by,1024);
}
}

void clientsock::OnReceive(int nErrorCode)
{
if(nErrorCode==0)
{
....
thread_c2=new mythread();
thread_c2->CreateThread();
}
}


Cn You Help Me? Thank You Very much!