Archived
This forum has been archived. Please start a new discussion on GitHub.
Question about souce codes "TcpEndpoint::acceptor"
OrNot
in Help Center
hi,there,
In the TcpEndpoint.cpp file,
AcceptorPtr
IceInternal::TcpEndpoint::acceptor(EndpointPtr& endp) const
{
TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port);
?????
endp = new TcpEndpoint(_instance, _host, p->effectivePort(), _timeout, _compress);
return p;
}
I can't understand the lines with "new" . why need such codes?
Consideration for reference number of smart pointer?
sorry for this trivial question.
Thanks in advance.
In the TcpEndpoint.cpp file,
AcceptorPtr
IceInternal::TcpEndpoint::acceptor(EndpointPtr& endp) const
{
TcpAcceptor* p = new TcpAcceptor(_instance, _host, _port);
?????
endp = new TcpEndpoint(_instance, _host, p->effectivePort(), _timeout, _compress);
return p;
}
I can't understand the lines with "new" . why need such codes?
sorry for this trivial question.
Thanks in advance.
0
Comments
-
hi, Benoit,
Sorry for my poor expression about my question. I mean, why need to allocate a new TcpEndpoint here? I traced into the code and found that the members of the new TcpEndpoint seem to have the same values as the one passed in by "EndpointPtr& endp" except the address and the ref. Why not use the original TcpEndoint in the accept() method ?
There must be some thing out of my understanding. Hope getting your help.
Best Regards---OrNot0
