|
You may encode binary data using, for instance, Base64 representation, see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
//XSocket is sub class of CSocket
XSocket*psk;
//connect etc.
assume:
psk->Send(...)
is guaranteed to send a message to other side.
If the socket is colosed immediately after Send(...) as
psk->Send(...);
psk->Close();
is the Send(...) function still guaranteed to send the message to other side?
|
|
|
|
|
I guess that if Send is a synchronous call, it is guaranteed to send the message when the function returns.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes, given that the 'other side' is connected and active, the operation is guaranteed. You might want to check the return value of XSocket::Send() , just in case...
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
includeh10 wrote: psk->Send(...)
is guaranteed to send a message to other side.
This just copies it into the socket send buffer, there is no guarantee that all data will be sent completely. Returning from CSocket::Send()[^] does not indicate that the remote peer has received all data. What you do might work in the LAN (in some cases), but it won't work reliable over the internet. Also see what's the proper way to close a TCP socket[^].
Hope it helps!
/M
|
|
|
|
|
Hi,
to capture video screen in DirectShow , I did as follwing...
it's woring well in case of *.wmv file...
but in case of *.avi didn't work...
After calling ...GetCurrentBuffer(&lBufferSize,NULL);
the value of lBufferSize is minus...(for example -2838382392 )
I don't know why lBufferSize is minus value...
void CTest::play()
{
m_pGB = NULL;
m_pMC = NULL;
m_pVW = NULL;
m_pBV = NULL;
m_pME = NULL;
m_pMS = NULL;
m_pSampleGrabber = NULL;
m_pSG = NULL;
CoInitialize(NULL);
CString m_file;
WCHAR wFileName[MAX_PATH];
TCHAR m_szFileName[MAX_PATH];
m_file = m_,"C:\\cs\\mds\\movie\\a.avi";
#ifndef UNICODE
MultiByteToWideChar(CP_ACP, 0, m_file , -1, wFileName, MAX_PATH) ;
#else
lstrcpy(wFileName, m_szFileName);
#endif
CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,IID_IGraphBuilder,(void**)&m_pGB);
CoCreateInstance(CLSID_SampleGrabber,NULL,CLSCTX_INPROC,IID_IBaseFilter,(void**)&m_pSampleGrabber);
m_pGB->AddFilter(m_pSampleGrabber,L"Sample Grabber");
AM_MEDIA_TYPE m_pMedia;
ZeroMemory(&m_pMedia,sizeof(m_pMedia));
m_pMedia.majortype = MEDIATYPE_Video;
m_pMedia.subtype = MEDIASUBTYPE_RGB24;
m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG);
if(m_pSG != NULL)
{
m_pSG->;SetMediaType(&m_pMedia);
m_pSG->SetBufferSamples(TRUE);
}
m_pGB->QueryInterface(IID_IMediaControl,(void**)&m_pMC);
m_pGB->QueryInterface(IID_IVideoWindow,(void**)&m_pVW);
m_pGB->QueryInterface(IID_IBasicVideo,(void**)&m_pBV);
m_pGB->QueryInterface(IID_IMediaEventEx,(void**)&m_pME);
m_pGB->QueryInterface(IID_IMediaSeeking,(void**)&m_pMS);
m_pGB->RenderFile(wFileName,NULL);
m_pMC->Run();
}
void CTest::ScreenShot()
{
m_pSampleGrabber->QueryInterface(IID_ISampleGrabber,(void**)&m_pSG);
if(m_pSG == NULL)
{
return;
}
long lBufferSize;
m_pSG->GetCurrentBuffer(&lBufferSize, NULL);
BYTE* pBuffer = new BYTE[lBufferSize];
if (!pBuffer)
return;
m_pSG->GetCurrentBuffer(&lBufferSize, (long *)pBuffer);
if (m_pSG != NULL)SaveImage(...);
delete pBuffer;
}
|
|
|
|
|
Please, read the posting guidelines before posting (use the code tags to format your code properly, to make it more readable).
For your question, did you check the return value of GetCurrentBuffer ? See the documentation[^]
|
|
|
|
|
Hey,
So I am just trying to utilize some of the built-ins for from the stl containers. I want to be able to store a class in a map, using one of the params as the key, and then retrieve it via an iterator.
It looks like this:
typedef std::string NodeName;
typedef std::set<NodeName> NodeSet;
typedef std::map<NodeName, NodeSet> NodeMap;
class Node : public std::pair <NodeName, NodeSet>
NodeMap NMap;
...some code...
I can insert objects easily enough:
Node n (...);
NMap.insert (n);
lets say i do that a bunch.
I then want to iterator over the map, extracting the data as I go.
for (NodeMap::iterator it = NMap.begin (); it != NMap.end (); it++)
{
Node &node = *it; <-- fails
}
I get the following error:
"~/testing/nodelist% g++ NodeList.C
NodeList.C: In function âvoid compute()â:
NodeList.C:40: error: cannot dynamic_cast â& itâ (of type âstruct std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >*â) to type âclass Node*â (source type is not polymorphic)
NodeList.C:51: error: âclass std::set<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >â has no member named âneighborhoodâ"
I tried dynamic casting but i couldn't seem to find it properly. Is there a legal way that I can do this? In the node class I made some handy little functions (nothing special), and I'd really like to be able to use them.
Could you please point out what my mistake is?
|
|
|
|
|
what you're doing looks terribly complex/convoluted - but anyway ..
you have an iterator 'it' to your map - which is a string 'NodeName' ->NodeSet , so,
it->first will be the string/NodeName
it->second will be the NodeSet
(ie, look up the properties of the iterator for a map)
|
|
|
|
|
Is their any standard formula to calculate time and space complexity of algo or please give me link to all above things r given..
|
|
|
|
|
Here[^] is what you could have found yourself.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
ohhh... I tried dis...but I didnt get wot I wanted exacly..
|
|
|
|
|
sam_psycho wrote: Is their any standard formula to calculate time and space complexity
Oh, no : too complex, both in space and time.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Oh, no : too complex, both in space and time. Big Grin
really? but I dont think it is toooooo complex...
|
|
|
|
|
|
|
Hi,
I woud Like to Use the CAsynSocket CLass as Member of CWinThread
In My Main Cwinthread I would like to Have 4 pointers to My CWinThreadSAsynSocket CLass'es
My question is the Following On Initinstance of the main thread
I would like to inistantiate them with the "new" operators and save thier m_thread id's
I Know that since CAsynSocket notfies completion via messages these Thread will have to be
of the UI variety
So. my question is When I want to pass them (threads a socket) to do work
I would ::Create the connection/socket
then Detach my socket and have them Attach the Socket
How do Notify them
Can I leave them in a Suspended status and do a Resume when I want them to take off
or since they are UI threads with a message pump they constantly have to be looping
and then my way of notifying them would be with PostThreadMessage ????
thankx
|
|
|
|
|
You shouldn't use Suspend/Resume, it has side effects, and it's meant to be used mostly by debuggers. It is better to use events[^].
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
This however is a UI thread with a Message Pump as CasyncSOcket post notificatins via messages
is it SAFE for a message Pump Thread to Wait for event Notification ????
|
|
|
|
|
I see your point. Well you can use MsgWaitForMultipleObjects[^], but even easier would be to use a user defined message instead of an event. One message to "start" and one message to "stop".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thankx
to Start CAsynSocketWinthread I can use PostMessageThread
I have to investigate and see how this works
In the Context of a Class or CWnd/Cdialog
thankx for the suggestion I will do some investigation
|
|
|
|
|
Forgot that CWnd/CDialog I have use message maps
Again thankx let me inestigate
|
|
|
|
|
It's something I did once when confronted with a similar problem. The code in your thread should look something like this pseudocode
if PeekMessage == MY_STOP_MESSAGE then
if GetMessage != MY_RESUME_MESSAGE then repeat
See the documentation in MSDN about PeekMessage and GetMessage
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hi,
Sorry about the Delay'ed reply I had to check out
MsgWaitForMultipleObjects
Since My Code is MFC using MESSAGE_MAPS
was wondering how to handle it
So...
I think I'll have to use the Overridable
CWnd/CDialog Windowproc
to get a first look at the messages before
they are dispatched to the message map
e.g
then if its a message I'll use Peekmessage to
Pull it off the queue
When I have both the Event set and the Message
I'll use the info pointed to by Lparm(which I
saved in some global) area to do my
processing
thankx
|
|
|
|
|
Actually if you use PostThreadMessage you don't need to use MsgWaitForMultipleObjects, as you'll be using messages *instead of* events (hence no need to use MsgWaitForMultipleObjects to wait for events).
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|