Try setting the type variant like below. MSDN says vbarray=8192 and vbbyte
=17 see below.
Well, like I said in my first post, the GetData seems to work fine when I
define the variant as a BSTR (see BSTR example below), however when I
define
the variants (var and varType) to retrieve the data as a array of bytes,
the
call to the GetData NEVER RETURNS- therefore i can't read the data to
answer
your question. Here is the code again that I use for an array of bytes
that
does not work:
void CWme_rwDlg::OnDataArrivalRxwfsock( long bytesTotal)
{
COleVariant var, varType, varLth(bytesTotal)
varType.iVal = VT_ARRAY | VT_I1);
varType.vt = VT_I2;
// GetData(VARIANT *data,
// const VARIANT &type,
// const VARIANT &maxLen)
GetData( &var, varType, varLth); // Winsock control getdata
AfxMessageBox("Get Data Succeeded");
}
I never get to the AfxMessageBox statement after the call to GetData. If
you see below, I show a code snipet that uses BSTR's to retrieve the data
and
that works, however I needed a byte array.
Thanks for your suggestion on using CAsynchSocket and that's probably the
way I've been leaning towards. I just started on the winsock.ocx path
(I've
used winsock in VB in the past) and couldn't understand why it would not
work
with byte arrays but work fine with BSTR's. I figured it was easier to
fix
a simple mistake in my code, then re-do my code using CAsyncSocket - but
it
looks like that's the way I'm going.
"Joseph M. Newcomer" wrote:
Do not use CSocket. Use CAsyncSocket. Then define what you mean by
"can't receive the
data".
joe
On Sat, 10 Jun 2006 08:26:01 -0700, mxa <mxa@discussions.microsoft.com>
wrote:
Kurt, thanks for the suggestion. It's exactly what I've been doing
since I
didn't get a response from anyone, and after many failed attempts using
the
OCX. It's just funny that I can send data fine, but I can't receive
the
data.
Thanks for your response and suggestion.
"Kurt" wrote:
Why not use one of the MFC classes like CSocket instead of the
winsock.ocx?
"mxa" <mxa@discussions.microsoft.com> wrote in message
news:AEDFF613-F746-4962-9533-46B3C2D42DEA@microsoft.com...
I'm attempting to use Winsock.ocx in a Visual Studio 6.0, C++
application
and
I have a question on how to pass variants to a winsock GetData
function
defined as follows: GetData(VARIANT *data, const VARIANT &type,
const
VARIANT
&maxLen).
I have no problems with other functions, but this particular
function
never
returns if I make the call with the VARIANT *data defined as a byte
array.
My question, is how would I go about getting the data as an Array of
Bytes?
What has worked is when I call the GetData as follows defining a
BSTR
type:
void CWme_rwDlg::OnDataArrivalRxwfsock( long bytesTotal)
{
COleVariant var, varType, varLth(bytesTotal)
varType.iVal = VT_BSTR;
varType.vt = VT_I2;
GetData( &var, varType, varLth); // Winsock control
getdata
function
Cstring str = (BSTR) var.bstrVal;
AfxMessageBox(str);
}
The above code works when sending a BSTR. However, I want to send
an
array
of bytes and have attempted to the following:
void CWme_rwDlg::OnDataArrivalRxwfsock( long bytesTotal)
{
COleVariant var, varType, varLth(bytesTotal)
varType.iVal = VT_ARRAY | VT_I1);
varType.vt = VT_I2;
GetData( &var, varType, varLth); // Winsock control
getdata
function
AfxMessageBox("Get Data Succeeded");
}
The number of bytes transmitted matches the number of bytes
received,
however when I call the GetData function, it never returns. I'm
assuming
I'm defining something incorrectly and was wondering if someone can
provide
me with some advice?
Expand AllCollapse All
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm