Passing Socket handles across process boundaries?? 
Author Message
 Passing Socket handles across process boundaries??

Hi All,
I've got an out-of-process COM server that has a socket listening on a
specific port. In the OnAccept handler, I'd like to call Accept to init a
new socket, then pass the new socket's handle to another process and just
forget about it within my server. Here's some code to help explain.

In my out-of-process server:

void CMyServer::ProcessPendingAccept()
{
    // Called from socket's OnAccecpt handler
 CSISocketBase socket;

 // Accept the connection using a temp CSocket object.
 SOCKADDR sockaddr;
 int nSockAddrLen = sizeof(sockaddr);
 if (m_sockListenConnData.Accept(socket, &sockaddr, &nSockAddrLen))
    // m_pOPSocketClient is a pointer to a COM object running in another
process
    m_pOPSocketClient->ProcessPendingAccept(socket.Detach());

Quote:
}

My client process is another .exe that calls CoCreateInstance on a MyServer
object;

STDMETHODIMP COPSocketClient::ProcessPendingAccept(long hSocket)
{
    m_Socket.Attach(hSocket);

Quote:
}

To summarize my question, how do you pass a socket handle from one exe to a
COM object in another exe? Is this possible?
Thanks for any help,
Wayne


Sun, 25 Jul 2004 05:29:06 GMT  
 Passing Socket handles across process boundaries??
Yes , look at http://tangentsoft.net/wskfaq/articles/passing-sockets.html
HTH
Arkady


Quote:
> Hi All,
> I've got an out-of-process COM server that has a socket listening on a
> specific port. In the OnAccept handler, I'd like to call Accept to init a
> new socket, then pass the new socket's handle to another process and just
> forget about it within my server. Here's some code to help explain.

> In my out-of-process server:

> void CMyServer::ProcessPendingAccept()
> {
>     // Called from socket's OnAccecpt handler
>  CSISocketBase socket;

>  // Accept the connection using a temp CSocket object.
>  SOCKADDR sockaddr;
>  int nSockAddrLen = sizeof(sockaddr);
>  if (m_sockListenConnData.Accept(socket, &sockaddr, &nSockAddrLen))
>     // m_pOPSocketClient is a pointer to a COM object running in another
> process
>     m_pOPSocketClient->ProcessPendingAccept(socket.Detach());
> }

> My client process is another .exe that calls CoCreateInstance on a
MyServer
> object;

> STDMETHODIMP COPSocketClient::ProcessPendingAccept(long hSocket)
> {
>     m_Socket.Attach(hSocket);
> }

> To summarize my question, how do you pass a socket handle from one exe to
a
> COM object in another exe? Is this possible?
> Thanks for any help,
> Wayne



Sun, 25 Jul 2004 15:07:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Can't pass IIDs properly across process boundaries

2. Can't pass IIDs properly across process boundaries

3. IPicture across process boundaries

4. Throwing com exceptions across process boundaries...

5. IXMLDOMNodeList across process boundaries?

6. Connection Point Events Across Processes Boundaries?

7. ? Passing Socket handle to process via pipe

8. Sockets sharing across different processes

9. Passing string across socket object reference

10. Socket handles across multiple threads

11. Understanding reference counts on com objects passed across processes

12. Passing interface pointer across process space

 

 
Powered by phpBB® Forum Software