Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » TcpSocket in Array
Re: TcpSocket in Array [message #37226 is a reply to message #37220] Fri, 07 September 2012 10:23 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
This would not work, as TcpSocket does not have any form of "copy".

Actually, this is sort of bug I have to fix (make copy constructor private).

I you really insist, you can use something like:

Array<TcpSocket> a;
TcpSocket *s = new TcpSocket;
s->...
if(...)
    a.Add(s);
else
    delete s;


anyway, that includes "new" which is not really "U++ish".

Other options:

One<TcpSocket> s;
s.Create();
s->...
if(...)
   a.Add(s.Detach());
// avoids need to delete (which you can forget to do ;)


TcpSocket& s = a.Add();
...
if(!...)
   a.Drop();


Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Skylark logs failure in accept()
Next Topic: TcpSocket Tutorials exist?
Goto Forum:
  


Current Time: Wed May 15 18:13:57 CEST 2024

Total time taken to generate the page: 0.01839 seconds