I tried to transplant a socket class from static dll to dynamic dll.But when I test it on my epoc thought ras,if in asy call(active object),it returns status code -2(KErrGeneral),if in syn call(WaitForRequest),it always break down. who can tell me why? thanks!

there is code:

//connect

HRESULT KSymSocket::SYNConnectByAddr(
struct TSocketAddr *addr,
const unsigned long /* lTimeout */)
{
if( m_SocketState == EUnconnected && m_iSockType == TTCPSocket)
{
TInetAddr iAddr;
AddrPerson2Sym(iAddr,*addr);
TRequestStatus tmpStatus;

m_RSocket.Connect(iAddr,tmpStatus);
User::WaitForRequest(tmpStatus);

if( iStatus == KErrNone )
{
m_SocketState = EConnected;
return S_OK;
}
else
{
return GetErrorFromStatus(tmpStatus);
}
}
else
{
return E_NOTINITIALIZED;
}
}



//Create Socket

HRESULT KSymSocket::CreateSocket(const unsigned int tSocketType)
{
if( m_iSockType == 0 )
{
CActiveScheduler::Add(this);
HRESULT result = CoGetClassObject(&CLSID_KTimer,&IID_ITimer,(void**)&m_lpTimer);
if( S_OK != result )
return result;
m_lpTimer->SetCallback(this);

User::LeaveIfError(m_RSocketServ.Connect());

if( tSocketType == TUDPSocket )
{
User::LeaveIfError( m_RSocket.Open(
m_RSocketServ,
KAfInet,
KSockDatagram,
KProtocolInetUdp) );
m_iSockType = TUDPSocket;
return S_OK;
}
else if( tSocketType == TTCPSocket )
{
User::LeaveIfError( m_RSocket.Open(
m_RSocketServ,
KAfInet,
KSockStream,
KProtocolInetTcp) );
m_iSockType = TTCPSocket;
return S_OK;
}
}

return E_EXCLUSIVE;
}