Nutritious Potato Munchies

    rainy-sctp

    0.0.3 • Public • Published

    SCTP Implementation for TypeScript

    Example

    import { createSocket } from "dgram";
    import { SCTP, WEBRTC_PPID } from "../src";
    import { createUdpTransport } from "../src/transport";
    
    const port = 5555;
    
    const socket = createSocket("udp4");
    socket.bind(port);
    
    const server = SCTP.server(createUdpTransport(socket));
    server.onRecieve = (_, __, data) => {
      console.log(data.toString());
      server.send(0, WEBRTC_PPID.STRING, Buffer.from("pong"));
    };
    
    const client = SCTP.client(
      createUdpTransport(createSocket("udp4"), {
        port,
        address: "127.0.0.1",
      })
    );
    client.onRecieve = (_, __, data) => {
      console.log(data.toString());
    };
    
    await Promise.all([client.start(5000), server.start(5000)]);
    await Promise.all([
      client.stateChanged.connected.asPromise(),
      server.stateChanged.connected.asPromise(),
    ]);
    
    client.send(0, WEBRTC_PPID.STRING, Buffer.from("ping"));

    reference

    Keywords

    none

    Install

    npm i rainy-sctp

    DownloadsWeekly Downloads

    0

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    76.6 kB

    Total Files

    76

    Last publish

    Collaborators

    • shinyoshiaki