Connecting Tech Pros Worldwide Forums | Help | Site Map

Sockets and filebuf with msvc 2003

Manfred Eckschlager
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi,

In Linux C++ there was an easy way to build a stream form a socket
like:

int sockFd = socket(AF_INET,SOCK_STREAM,0);

filebuf *netBuf = new filebuf( sockFd );
-and then
iostream *netStream = new iostream(filebuf);

But the new stream headers in VC.net 2003 dont support attach(int fd)
and filebuf(int) anymore.
Is there another short msvc like way to attach a stream to a socket?

thx, cheers
Manfred

John Harrison
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Sockets and filebuf with msvc 2003



"Manfred Eckschlager" <eckschi@yahoo.com> wrote in message
news:4693bd71.0407190147.72695e59@posting.google.c om...[color=blue]
> Hi,
>
> In Linux C++ there was an easy way to build a stream form a socket
> like:
>
> int sockFd = socket(AF_INET,SOCK_STREAM,0);
>
> filebuf *netBuf = new filebuf( sockFd );
> -and then
> iostream *netStream = new iostream(filebuf);
>
> But the new stream headers in VC.net 2003 dont support attach(int fd)
> and filebuf(int) anymore.
> Is there another short msvc like way to attach a stream to a socket?
>
> thx, cheers
> Manfred[/color]

No short way in standard C++. If you want an VC++ specific answer then ask
on a VC++ group.

You should write your own stream classes for this sort of thing. It's not
that difficult, 'The C++ Standard Library' by Josuttis explains how.

john


tom_usenet
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Sockets and filebuf with msvc 2003


On 19 Jul 2004 02:47:22 -0700, eckschi@yahoo.com (Manfred Eckschlager)
wrote:
[color=blue]
>Hi,
>
>In Linux C++ there was an easy way to build a stream form a socket
>like:
>
>int sockFd = socket(AF_INET,SOCK_STREAM,0);
>
>filebuf *netBuf = new filebuf( sockFd );
>-and then
>iostream *netStream = new iostream(filebuf);
>
>But the new stream headers in VC.net 2003 dont support attach(int fd)
>and filebuf(int) anymore.
>Is there another short msvc like way to attach a stream to a socket?[/color]

There is no standard way to do this, so it is off-topic for this
group; you should ask in an MSVC-specific newsgroup. (Hint,
std::filebuf::filebuf(FILE*))

Tom
Closed Thread