HP-Socket icon indicating copy to clipboard operation
HP-Socket copied to clipboard

Can i use customized client class in CTcpServer?

Open mnt-github opened this issue 1 year ago • 1 comments

I want to use customized client class pointer in CTcpServer.

/* Customized client class */
class MyClient
{
    ...
}




/* CTcpServer OnAccept */
EnHandleResult MyServer::OnAccept(ITcpServer* pSender, CONNID dwConnID, UINT_PTR soClient)
{
    ...
    MyClient *ptr = new MyClient();    // Create Client Point
    
    // I want to register **ptr** to Server.
    
    return HR_OK;
}

EnHandleResult MyServer::OnReceive(ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength)
{
    ...
    
    // I want to get **Client Class Ptr** from Server.
    
    return HR_OK;
}

What should I do?

mnt-github avatar Jun 28 '24 00:06 mnt-github

这是来自樊  邮箱的自动回复邮件。 您好,您发的邮件我已收到,我会及时查看并予以回复。

FunlyDay avatar Jun 28 '24 00:06 FunlyDay

Yes, use SetConnectionExtra() to hold the custom data.
refer to \Windows\Demo\HttpProxy

ldcsaa avatar Jul 11 '24 18:07 ldcsaa