
"Christopher Kohlhoff" <chris@kohlhoff.com> wrote in message news:20050818224433.68637.qmail@web32607.mail.mud.yahoo.com...
3. why is everything public in a host?
Only because the host represented data without behaviour, but if a class with member functions is preferred I can do it that way.
it is not much that the data is without behavior...is the data without invariants...do all posssible configurations of those data rmain legal values for the program? (I doubt they do)
4. why does both the stream_socket and the socket_connector need to know about the demuxer? Can't the socket_connector ask the stream_socket for its demuxer (I want to simplify usage if possible)
This may be moot if asio is changed to use connect/async_connect functions on the socket itself. What do you think of that change?
I'm not quailfied to comment on that.
As others have commented, vector<char> can introduce a performance hit due to default construction of the elements. Also, some applications need to send data structures directly, to avoid additional copies. So I'd prefer to keep the operations on the socket class itself using void*.
please consider the other mails too. there are too many drawback in void* IMO. I have seen/used code where a statically allocated data was far slower than putting it on the heap. This wsa not stack-allocated, but static data. So I'm a bit concerned about performance claims. With a vector it should't be difficult to pull the construction out-side the loop. From then on it would have a fixd size.
However, IMHO the place for supporting high level types is in non-member functions like asio::send and asio::recv. E.g.
template <typename SyncStream, typename InputIterator, typename Handler> size_t send_range( SyncStream& s, InputIterator begin, InputIterator end, size_t* total_bytes_sent = 0);
template <typename AsyncStream, typename InputIterator, typename Handler> void async_send_range( AsyncStream& s, InputIterator begin, InputIterator end, Handler handler);
I believe that it's in these sorts of functions that asio offers the most extensibility. Would it be useful to add functions like this to the library itself, and what form should they take?
If the only performance sensible iterator types are T*, I would't mind simply template< unsigned N > void receive( char (&)[N] ); template< unsigned N > void receive( char (&)[N], unsigned size ); void recieve( vector<char>& ); void recieve( vector<char>&, unsigned size ); or something. I have a hard time imagining any overhead imposed by vector<char> compared to a heap-allocated char*. br Thorsten