npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nativescript-simple-networking

v0.1.1

Published

UDP and TCP sockets for NativeScript

Readme

NativeScript Simple Networking

Basic UDP and TCP sockets for NativeScript.

Supported platforms

  • Android (any device with Android 4.4 and higher)

There is no support for iOS (yet), as I am not an iOS developer. Contributions for adding iOS support are welcome!

Installing

tns plugin add nativescript-simple-networking

Usage

This plugin provides three classes: UdpServer, TcpClient and TcpServer. All of them provide similar, callback-based, interface. An example of usage is worth a thousands words and therefore here is a TypeScript example:

import {UdpServer, TcpClient, TcpServer} from "nativescript-simple-networking";
import {Address4} from "ip-address";

var udpServer = new UdpServer();
udpServer.onPacket = (sender: Address4, message: string) => {
    console.log("Message from UDP: ", message);
};
udpServer.onError = (id: number, message: string) => {
    console.log("UDP error for action #", id, ": ", message);
};
udpServer.onFinished = (id: number) => {
    console.log("UDP finished action #", id);
};

// Start listening on port 33333
var udpConnectEvent: number = udpServer.start(33333);
console.log("UDP start event is: ", udpConnectEvent);
// Broadcast a message
var udpBroadcastEvent: number = udpServer.send("255.255.255.255", "I am alive!");
console.log("UDP broadcast event is: ", udpBroadcastEvent);

// Start a TCP server listening on port 44444 with maximum 2 clients
var tcpServer = new TcpServer(2);
tcpServer.onClient = (client: Address4) => {
    console.log("New TCP client: ", client.adddress)
    tcpServer.send(client, "Welcome!");
};
tcpServer.onData = (client: Address4, data: string) => {
    console.log("New data from client ", client.address, ": ", data);
};
tcpServer.onError = (id: number, client: Address4, message: string) => {
    if (client)
        console.log("TCP server client error", client.address, ": ", message);
    else
        console.log("TCP server error: ", message);
};
tcpServer.onFinished = (id: number) => {
        console.log("TCP server finished transaction #", id);
};

tcpServer.start(44444);

// Connect to the TCP server
var tcpClient = new TcpClient();
tcpClient.onData = (data: string) => {
    console.log("Data from TCP client: ", data);
};
tcpClient.onError = (id: number, message: string) => {
    console.log("TCP client error for action #", id, ": ", message);
};
tcpClient.onFinished = (id: number) => {
    console.log("TCP client finished action #: ", id);
};

// Connect client, action IDs are ommited in this example - see UdpServer
tcpClient.start("localhost", 44444);
tcpClient.send("I am also alive!");

// When we are finished
udpServer.stop();
TcpServer.stop();
TcpClient.stop();

Contributing

Any contributions are welcome, feel free to submit a pull request on GitHub. I would appreciate a PR, which would add support for iOS.

Future Plans

  • support iOS
  • implement a wrapper for future-based interface