May 5th, 1999, 03:23 PM
I am attempting to use the 'Microsoft Winsock Cotnrol 6.0' in a C++ application, but without much success. I create the control in the usual COM way and do know that I am successful as I can display the controls' aboutBox.
Here is my problem, when I try to connect to the remote host (actually a loopback), the connection is never completed, therefore I can send nothing through the socket without getting an exception. Here is the code:
IMSWinsockControlPtr pWinsockCtrl = NULL;
HRESULT hResult = pWinsockCtrl.CreateInstance( __uuidof( Winsock ));
if( FAILED( hResult ))
{
return E_FAIL;
}
_variant_t varIPAddress( _T("127.0.0.1"));
_variant_t varPortID( 9999L );
_variant_t varData( _T("This is a test"));
hResult = pWinsockCtrl->Connect( varIPAddress, varPortID );
if( FAILED( hResult ))
{
return E_FAIL;
}
pWinsockCtrl->SendData( varData ); // <<<<<<<------ throws exception
pWinsockCtrl->Close();
Has anyone successfully used this control from C++ and is so, could you possibly send me some working code (or at least tell me what I am doing wrong).
Thanks!!
Barry
Here is my problem, when I try to connect to the remote host (actually a loopback), the connection is never completed, therefore I can send nothing through the socket without getting an exception. Here is the code:
IMSWinsockControlPtr pWinsockCtrl = NULL;
HRESULT hResult = pWinsockCtrl.CreateInstance( __uuidof( Winsock ));
if( FAILED( hResult ))
{
return E_FAIL;
}
_variant_t varIPAddress( _T("127.0.0.1"));
_variant_t varPortID( 9999L );
_variant_t varData( _T("This is a test"));
hResult = pWinsockCtrl->Connect( varIPAddress, varPortID );
if( FAILED( hResult ))
{
return E_FAIL;
}
pWinsockCtrl->SendData( varData ); // <<<<<<<------ throws exception
pWinsockCtrl->Close();
Has anyone successfully used this control from C++ and is so, could you possibly send me some working code (or at least tell me what I am doing wrong).
Thanks!!
Barry