Sockets and filebuf with msvc 2003

  • Thread starter Manfred Eckschlager
  • Start date
M

Manfred Eckschlager

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
 
J

John Harrison

Manfred Eckschlager said:
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

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
 
T

tom_usenet

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?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top