Sign in to follow this  

Is there any need for this? *library*

This topic is 4528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am just wondering if anyone here needs a cross platform c++ library for sockets programming? I am currently working on a library with the following features/properties for a private project that needs to run on windows and linux servers: it features the following: - wrapper for sockets - some routines to setup sockets with a single function call to reduce the amount of code you have to write to get it working - all socket functions wrapped use BOOL to determine success or failure the send and receive functions got an extra parameter by reference to get the number of bytes written/read - a few things i ll add to the library are a pooled allocator which can be used with stl lists to reduce memory fragmentation and maybe some other useful things i need in the project cya

Share this post


Link to post
Share on other sites
i am still working on maybe at the end of the week maybe a little bit earlier i am still writing the allocator for stl and need to run some tests to verify the specifications

Share this post


Link to post
Share on other sites
A socket library modeled after - and, even, interchangable with - std::streams would be very nice.

Also; unless this pooled allocator is used directly by the library, do not include it. It isn't part of that library.

Share this post


Link to post
Share on other sites
doing this is pretty easy

the iostreams are modelled on top of the stdin and stdout and stderr *at least thats what i have read in the headers*

on linux sockets are just filedescriptors which you can duplicate with dup2 see "man 2 dup2"
so all you do is you use dup2 on stdin and stout and voila done

on windows this is a little bit more difficult, in fact i know of no way to redirect the stdin and stdout to a socket

the poor posix implementation they have shall be broken so i don t know if its possible at all


does anyone know?

Share this post


Link to post
Share on other sites
Well you're basicly off-base to begin with, sure cout, cin, cerr and clog are bound to stdout, stdin and stderr by default but they're not "modled" after them. They use streambuf's to handle output basicly what you want to do is create a customized streabuf using a socket then you can rebind any stream (including standardstreams) to use that streambuf.

The process is a bit simpler on unices since you can create a file based streambuf and connect that to a socket but since your'e doing a socket library that shouldn't really matter much.

Share this post


Link to post
Share on other sites
hm am i right in the assumption that i only have to overwrite the get and put functions of streambuf?

if yes ill propably mess around with it

Share this post


Link to post
Share on other sites
i just read through around 20 pages of stream documentation
http://www.atnf.csiro.au/computing/software/sol2docs/manuals/stdlib/user_guide/loc_io/18_3.htm

here they give a pretty good example on how to proceed

derive streambuf

implement your buffer and socket work there

overwrite some member functions

and with the operator=(streambuf &..) you assign it to the stream you want to use

i am not sure if i will put this into the first release

Share this post


Link to post
Share on other sites

This topic is 4528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this