Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > writing and readig on virtual interface /dev/tapX

Reply
Thread Tools

writing and readig on virtual interface /dev/tapX

 
 
fabrizio
Guest
Posts: n/a
 
      11-11-2005
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

 
Reply With Quote
 
 
 
 
John Ratliff
Guest
Posts: n/a
 
      11-11-2005
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:ut);

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading and writing to a virtual directory =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?= ASP .Net 4 10-04-2005 12:17 AM
virtual template and virtual access for ADSL circuits Gary Cisco 1 04-28-2005 07:26 PM
virtual function and pure virtual function in the implementation of COM IK C++ 2 07-23-2004 02:55 PM
static nat between phisical interface and virtual interface on same ethernet Andrea Cisco 0 04-19-2004 09:37 AM
Virtual functions and virtual base classes - I'm confused Michael Winter C++ 9 09-23-2003 11:17 PM



Advertisments