Click here to Skip to main content
15,914,289 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Which lib is corresponding to Dskquota.h? Pin
Le centriste18-Sep-02 6:22
Le centriste18-Sep-02 6:22 
GeneralRe: Which lib is corresponding to Dskquota.h? Pin
Anonymous18-Sep-02 8:04
Anonymous18-Sep-02 8:04 
GeneralMaking Right align Rich Edit box ! Pin
Hadi Rezaee18-Sep-02 4:07
Hadi Rezaee18-Sep-02 4:07 
GeneralProblem with SQL FETCH Pin
Cheickna18-Sep-02 4:04
Cheickna18-Sep-02 4:04 
GeneralRe: Problem with SQL FETCH Pin
TyMatthews18-Sep-02 5:10
TyMatthews18-Sep-02 5:10 
GeneralPassing a file through a Socket Pin
RobJones18-Sep-02 3:44
RobJones18-Sep-02 3:44 
GeneralRe: Passing a file through a Socket Pin
TyMatthews18-Sep-02 5:57
TyMatthews18-Sep-02 5:57 
GeneralRe: Passing a file through a Socket Pin
Bilal18-Sep-02 6:32
Bilal18-Sep-02 6:32 
why not use archives to simplify things?
Sending code would be
<br />
CSocket cSocket;<br />
cSocket.Create();<br />
cSocket.Connect((LPCTSTR(m_strServerIP)),m_iFtPort);<br />
<br />
CSocketFile sf(&cSocket);<br />
CArchive ar(&sf, CArchive::store);<br />
<br />
/*code for CFileDialog goes here*/<br />
//if IDOK<br />
   strPath = m_ldFile.GetPathName();<br />
   CFile myFile(strPath,<br />
     CFile::modeRead | CFile::typeBinary);		<br />
   <br />
   //get file info <br />
   DWORD length = myFile.GetLength();<br />
   char *data = new char[length];<br />
   myFile.Read(data, length);<br />
<br />
   //send it across<br />
   ar << myFile.GetFileName();<br />
   ar << length;<br />
   ar.Write(data, length);<br />
<br />
   delete[] data;<br />
   myFile.Close(); 	<br />


and on the receiving side, just the reverse process
<br />
//after accepting the connection with pSocket<br />
   CSocketFile sf(pSocket);<br />
   CArchive ar(&sf, CArchive::load);<br />
<br />
   //create file...<br />
   CString filename;<br />
   ar >> filename;<br />
   CFile m_destFile(filename,<br />
       CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);<br />
<br />
   DWORD length;<br />
   char *data;<br />
   <br />
   //get data<br />
   ar >> length;<br />
   data = new char[length];<br />
   ar.Read(data, length);<br />
<br />
   //wrap up<br />
   m_destFile.Write(data, length);<br />
   m_destFile.Flush();<br />
<br />
   delete[] data;<br />
   m_destFile.Close();<br />

I don't know about the do..while for the Read/Write though, this code is working fine for me Smile | :)

Bilal Naveed
GeneralRe: Passing a file through a Socket Pin
RobJones18-Sep-02 6:57
RobJones18-Sep-02 6:57 
GeneralRe: Passing a file through a Socket Pin
RobJones18-Sep-02 11:06
RobJones18-Sep-02 11:06 
GeneralRe: Passing a file through a Socket Pin
Bilal18-Sep-02 20:42
Bilal18-Sep-02 20:42 
GeneralUTF-8 to Unicode or ANSI. Pin
Halls18-Sep-02 3:25
Halls18-Sep-02 3:25 
GeneralRe: UTF-8 to Unicode or ANSI. Pin
Stephane Rodriguez.18-Sep-02 3:37
Stephane Rodriguez.18-Sep-02 3:37 
GeneralAfxBeginThread Pin
vampiras^18-Sep-02 3:15
sussvampiras^18-Sep-02 3:15 
GeneralRe: AfxBeginThread Pin
Chris Meech18-Sep-02 3:55
Chris Meech18-Sep-02 3:55 
QuestionHow to pass address of a method to a function Pin
Raphael Kindt18-Sep-02 3:06
Raphael Kindt18-Sep-02 3:06 
AnswerRe: How to pass address of a method to a function Pin
Stephane Rodriguez.18-Sep-02 3:40
Stephane Rodriguez.18-Sep-02 3:40 
AnswerRe: How to pass address of a method to a function Pin
Joaquín M López Muñoz18-Sep-02 4:08
Joaquín M López Muñoz18-Sep-02 4:08 
AnswerRe: How to pass address of a method to a function Pin
Axter18-Sep-02 5:16
professionalAxter18-Sep-02 5:16 
Generalstd::string Pin
Furrukh18-Sep-02 2:15
Furrukh18-Sep-02 2:15 
GeneralRe: std::string Pin
jhwurmbach18-Sep-02 2:31
jhwurmbach18-Sep-02 2:31 
GeneralRe: std::string Pin
Joaquín M López Muñoz18-Sep-02 4:05
Joaquín M López Muñoz18-Sep-02 4:05 
GeneralRe: std::string Pin
Axter18-Sep-02 5:31
professionalAxter18-Sep-02 5:31 
GeneralProcessing Speed Pin
:_Rocket_:18-Sep-02 1:45
:_Rocket_:18-Sep-02 1:45 
GeneralScrollbar Drawing Pin
Jawache18-Sep-02 1:22
Jawache18-Sep-02 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.