|
In that case I cann't use AfxBeginthread to Create the derived CWinthread as the CwinThread constructer return by the Helper AfxBeginthread doesn't take any paramters
MyCWinThread :: MyCwinthread(int port) : Myasncsocket(port)
I would then also have to Call MyCwinthread::Createthread as I beleive the Framework Helper function does both correct
|
|
|
|
|
AfxBeginThread is just a helper, there's no need to use that if it doesn't fit your needs, but it seems like you got the gist of things.
|
|
|
|
|
here is data (in ASCII format) downloaded from server by command "LIST":
total 1100
-rw------- 1 root 38 Dec 16 2010 .bash_history
(omitting several lines here)
drwx--x--x 6 other 512 Oct 13 2005 usr
My question is:
How do I know the downloading is completed?
I guess I need to send count of bytes downloaded to server, so server will tell if downloading is OK.
If so,
What instruction (command) should I send to server?
Which port (command port or data port) should I use for sending the instruction?
Thanks.
.
|
|
|
|
|
Is this something to do with C++ or are you just trying to understand how to use FTP? If you are doing this programmatically then you just keep reading the socket until no more data is presented.
includeh10 wrote: Which port (command port or data port) should I use
Not sure that I understand your question here; what do you mean by "command port or data port"?
|
|
|
|
|
See RFC 959[^], section 4.2 (FTP Replies).
Just check for three digits followed by a space at the begin of each line. With the LIST command, it is usually the code 250 followed by server dependant text, e.g.:
125 List started OK.
[list output]
250 List completed successfully.
|
|
|
|
|
I got a exception on CAsynSocket::create
not sure why ??? memory exception, sock err
so as per my earlier thread I generated this huge catch(s) block
my question is the following if its a socket error
will the catch for derived CInternetException catch the error
my socket has 2 machines communicating not necessarly the Internet
void allexceptions::mycatch()
{
CRuntimeClass* runtimeptr;
runtimeptr = GetRuntimeClass();
try{}
catch(CMyexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_EXCEPTION_THREAD);
}
catch(CMysimpleexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_SIMPLE_EXCEPTION_THREAD);
}
catch(CMyinvalidargexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_INVALIDARG_THREAD);
}
catch(CMymemoryexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_MEMORY_THREAD);
}
catch(CMynotsupportedexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_NOTSUP_THREAD);
}
catch(CMyarchiveexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_ARCHIVE_THREAD);
}
catch(CMyfileexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_FILE_THREAD);
}
catch(CMyresourceexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_RESOURCE_THREAD);
}
catch(CMyoleexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_OLE_THREAD);
}
catch(CMydbexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_DB_THREAD);
}
catch(CMyoledispatchexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_OLEDISP_THREAD);
}
catch(CMyuserexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_USER_THREAD);
}
catch(CMydaoeexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_DA_THREAD);
}
catch(CMyinternetexception e)
{
if (strcmp(runtimeptr->m_lpszClassName,"CWinThread") == 0)
ReportError(MB_OK,IDR_INTER_THREAD);
}
}
|
|
|
|
|
Hello!
I am currently working on a mid-scale project and compiling and linking worked perfect until now. I played around with my resource files and the linker won't eat my object files anymore:
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
I already deleted the resource file, the resource header and made them new about 5 times, I removed all possibly deprecated object and pch files and restartet Visual Studio countless times, but it still won't work.
Any ideas?
|
|
|
|
|
What were you doing to what resource file?
In any case, considering what you've already tried... you can always start a new project and transfer your code over.
|
|
|
|
|
Albert Holguin wrote: What were you doing to what resource file?
I don't remember exactly what I did, but I don't think that matters because I've deleted the old resource file and made a new one a dozen times.
modified 30-Jun-12 8:28am.
|
|
|
|
|
Are you certain this is because of your resource changes? Have you tried doing a clean of your project, deleting all object files and rebuilding from scratch?
|
|
|
|
|
Yeah. Because when I exclude the resource file from the project, everything works as expected. As soon as I add a resource file (even an empty one) it starts doing that.
Edit: By empty I mean that no icons, bitmaps et cetera are in the resource, the file itself contains the default text.
modified 30-Jun-12 11:46am.
|
|
|
|
|
Never seen that before, I can only assume there is some corruption elsewhere on your system. Looking at some of the Google finds for that Link error I noticed a number that suggested either a system restore, or the use of a special recovery tool or both. you may wish to research some of those suggestions yourself. As a last resort you can always try the Microsoft Development Q&A - I don't have the address but I have used it in the past and got some useful feedback.
|
|
|
|
|
You know the dsp and dsw files are just text and can be edited to clean up a project? Could be you have some ting bad in one of them from what you are saying.
|
|
|
|
|
Hi Forum,
i try to open a *.chm File with a HtmlHelp() API this part works if i want to go to specific topic this all works fine.
I have a problem if i want to open my *.chm file with a HH_DISPLAY_SEARCH option.
I open my file and the "search" tab is selected, but search routine is not started?
On MSDN site http://support.microsoft.com/kb/241381[^] says that this don't work yet.
Does any one know a alternative for this?
Or is there any way to do this with hh.exe and "mk:@MSITStore:"??
Thanks for Help
bosfan
|
|
|
|
|
solved
|
|
|
|
|
typedef std::set<int> _OWN_TYPE;
_OWN_TYPE s;
int n = 10;
while(n--)
s.insert(n);
std::copy(s.begin(), s.end(), std::ostream_iterator<int>(std::cout, "\t"));
std::cout << std::endl;
cout << typeid(_OWN_TYPE::iterator).name() << endl;
std::vector<_OWN_TYPE::iterator> vec;
Now I'm confused about how to put the interator in [s.begin(), s.end()] into vec by one line code(I would prefer it occur in the construction of vec).
I don't want to use the following code, it's redundancy :
for (_OWN_TYPE::iterator itr = s.begin(); itr != s.end(); ++itr)
{
vec.push_back(itr);
}
Any one can help me?
|
|
|
|
|
|
No, it doesn't help.
What I want to do is put the iterator of std::set<int> s to std::vector ...
Thank you all the same!
|
|
|
|
|
you want to copy the std::set to a std::vector ?
just use something like :
std::vector<_OWN_TYPE::iterator > vec;
std::copy(s.begin(), s.end(), std::back_inserter(vec));
Watched code never compiles.
|
|
|
|
|
Your code can't compile...
Thank you for you reply.
|
|
|
|
|
How about abstracting the construction into a function as it's hard to grab the extra level of indirection using a vector constructor or an algorithm:
std::vector<std::set<int>::iterator> build_index( const std::set<int> &s )
{
std::vector< std::set<int>::iterator > index;
for( auto iter( s.begin() ); iter != s.end(); ++iter )
{
index.push_back( iter );
}
return index;
}
int main()
{
int set_initialisers[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
std::set<int> s( std::begin( set_initialisers ), std::end( set_initialisers ) );
std::vector< std::set<int>::iterator > index( build_index( s ) );
} It's not that inefficient in C++98 as it'll probably trigger NRVO and in C++11 it'll use the move constructor for vector.
|
|
|
|
|
Thank you very much!
It does work. You are great!
|
|
|
|
|
Be very careful about using this sort of thing - as others have mentioned it's probable that your design isn't quite what you think it is (for example setting things of multiple types through an interface).
Good luck though and nice to see someone actually using <algorithm> in their work!
|
|
|
|
|
Another question, I have to use std::sort like this:
bool func(set<int>::iterator lhs, set<int>::iterator rhs)
{
return *lhs > *rhs;
}
|
|
|
|
|
Another question, I have to use std::sort like this?
bool func(set<int>::iterator lhs, set<int>::iterator rhs)
{
return *lhs > *rhs;
}
sort(vec.begin(), vec.end(), func);
How can I use
std::copy(vec.begin(), vec.end(), std::ostream_iterator<<big>???</big>>(std::cout, "\t"));
|
|
|
|