rx-udp
Use observers and observables to read and write from udp sockets
Install
npm i -S rx-udp
Reading from a socket
Use the following snippet to create an Observable<string>
to read messages from a socket:
const rxUdp = ;const dgram = ;const server = dgram;const observable = rxUdp;server;
Writing to a socket
Use the following snippet to create an Observer<string>
to send messages to a specific server:
const rxUdp = ;const dgram = ;const client = dgram;const observer = rxUdp;
Echo program
You can create an (overly complicated) echo application:
const RxNode = ;const dgram = ;const rxUdp = ; const SERVER_PORT = 9999;const SERVER_HOST = "localhost"; // setup serverconst server = dgram;const serverObservable = rxUdp;server; // setup clientconst client = dgram;const clientObserver = rxUdp; // pipe stdin to clientconst subscription = RxNode; // pipe stdout to serverRxNode;
Contributing
Feel free to open issues with questions/bugs/features. PRs are also welcome.
License
MIT