Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-20-2005
OrNot OrNot is offline
Registered User
 
Name: Bin.Li
Organization: GE Healthcare
Project: Enterprise solution
 
Join Date: Jun 2005
Location: Shanghai
Posts: 156
Send a message via MSN to OrNot
-->
Question about souce codes "TcpEndpoint::acceptor"

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.
Reply With Quote
  #2 (permalink)  
Old 06-20-2005
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,534
Hi,

The "endp" argument is passed by reference and is used as a return value for the accept() method. The use of a smart pointer ensures that the caller won't have to take care of the deallocation of the TcpEndpoint object.

I hope this is clearer!

Benoit.
Reply With Quote
  #3 (permalink)  
Old 06-20-2005
OrNot OrNot is offline
Registered User
 
Name: Bin.Li
Organization: GE Healthcare
Project: Enterprise solution
 
Join Date: Jun 2005
Location: Shanghai
Posts: 156
Send a message via MSN to OrNot
-->
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---OrNot
Reply With Quote
  #4 (permalink)  
Old 06-20-2005
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,534
I don't think it's exactly the same -- the port might be different for instance.

Benoit.
Reply With Quote
  #5 (permalink)  
Old 06-20-2005
OrNot OrNot is offline
Registered User
 
Name: Bin.Li
Organization: GE Healthcare
Project: Enterprise solution
 
Join Date: Jun 2005
Location: Shanghai
Posts: 156
Send a message via MSN to OrNot
-->
Thank you Benoit.
Maybe the method "effectivePort()" is the key. I will test it further.


OrNot
Reply With Quote
  #6 (permalink)  
Old 06-20-2005
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
If you do not specify a port number, the operating system will choose one. endp returns an endpoint with that port number.
Reply With Quote
  #7 (permalink)  
Old 06-20-2005
OrNot OrNot is offline
Registered User
 
Name: Bin.Li
Organization: GE Healthcare
Project: Enterprise solution
 
Join Date: Jun 2005
Location: Shanghai
Posts: 156
Send a message via MSN to OrNot
-->
Oh yeah!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't "Ice-3.1.1-VC71.msi " include the "slice2java.exe"? Jason Gao Help Center 4 10-26-2006 12:23 PM
Icepack registry "TimeOut" exception with heavy load eaglecn Help Center 1 05-26-2006 01:02 AM
"Invalid UTF8 string" when transer chinese chars between cpp server and csharp client raygo Help Center 8 03-21-2006 09:34 PM
Question about "Ice.MonitorConnections" OrNot Help Center 2 07-21-2005 12:27 AM
Going from "in" to "out" param, using a class as a union catalin Help Center 1 04-05-2004 09:55 AM


All times are GMT -4. The time now is 10:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.