How to pass variant (array of bytes) to winsock.ocx
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