By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,903 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,903 IT Pros & Developers. It's quick & easy.

writing and readig on virtual interface /dev/tapX

P: n/a
I have to write an application which read from a virtual interface
/dev/tap0, write the packets on /dev/tap1 on the same machine and
viceversa (I have to emulate a network, with packets loss etc...).
I don't know how to open the stream. Should I use fstream? If so, can I
open a stream in input and output mode at the same time?

Thanks.
fabrizio

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
fabrizio wrote:
I have to write an application which read from a virtual interface
/dev/tap0, write the packets on /dev/tap1 on the same machine and
viceversa (I have to emulate a network, with packets loss etc...).
I don't know how to open the stream. Should I use fstream? If so, can I
open a stream in input and output mode at the same time?


Should be able to.

#include <fstream>
#include <iostream>

std::fstream in("/dev/tap0", std::ios::in);
std::fstream out("/dev/tap1", std::ios::out);

Then you could overload the stream operators for your packet class to
handle reading/writing.

As far as read/write at once, you can or the in and out properties, but
from what you've said, I don't know why you would want to.

--John Ratliff
Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.