Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use it ? #11

Open
tchereau opened this issue Aug 1, 2022 · 7 comments
Open

How to use it ? #11

tchereau opened this issue Aug 1, 2022 · 7 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed StreamsAPI make it support StreamsAPI of node

Comments

@tchereau
Copy link

tchereau commented Aug 1, 2022

I created the tap
now how can I push input and read output ?
in example, if I have a serveur and a client, I've create a server, and both script can connect, now I can read data from one tap, and send it to the other ?

@tchereau
Copy link
Author

tchereau commented Aug 1, 2022

I readed the StreamAPI test unit, but there's no docs, I guess I have to use tap.pipe()/unpipe() and push/unshift, but how ?

@PupilTong
Copy link
Owner

PupilTong commented Aug 1, 2022 via email

@PupilTong
Copy link
Owner

if you have another Stream, use pipe()
If not, use
tun.write
tun.once('data', ()=>{})
tun.on('data',()=>{})

Docs will be improved, Thanks!

@PupilTong PupilTong added documentation Improvements or additions to documentation help wanted Extra attention is needed StreamsAPI make it support StreamsAPI of node enhancement New feature or request labels Aug 2, 2022
@PupilTong
Copy link
Owner

More specified examples will be posted soon.

@tchereau
Copy link
Author

tchereau commented Aug 4, 2022

if you have another Stream, use pipe() If not, use tun.write tun.once('data', ()=>{}) tun.on('data',()=>{})

Docs will be improved, Thanks!

thanks I will try it :)

@tchereau
Copy link
Author

tchereau commented Aug 4, 2022

It worked, using to machin on different network, and net library, both are connecting, and I can ping each other with the specified ipv4

client (under net.connect):

        client.on('data', (buf) => {
            console.log(`received: ${buf}`);
            tap.write(buf);
        });
        tap.on('data', (buf) => {
            console.log(`sent: ${buf}`);
            client.write(buf);
        });
    }

server (same, using net.connect):

        c.on('data', (buf) => {
            console.log(`received: ${buf}`);
            tap.write(buf);
        });
        tap.on('data', (buf) => {
            console.log(`sent: ${buf}`);
            c.write(buf);
        });
    }

image
image

@sosoba
Copy link

sosoba commented Jun 14, 2024

Is there fixed rule: one call to tap.write(buf); are one network package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed StreamsAPI make it support StreamsAPI of node
Projects
None yet
Development

No branches or pull requests

3 participants