{"id":15141988,"url":"https://github.com/yaqwsx/nativescript-simple-networking","last_synced_at":"2025-10-23T19:30:58.841Z","repository":{"id":57308755,"uuid":"85518124","full_name":"yaqwsx/nativescript-simple-networking","owner":"yaqwsx","description":"UDP and TCP sockets for NativeScript","archived":false,"fork":false,"pushed_at":"2020-01-24T17:18:53.000Z","size":195,"stargazers_count":19,"open_issues_count":4,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T20:30:32.539Z","etag":null,"topics":["android","nativescript","nativescript-plugin","network","networking"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaqwsx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-20T00:00:12.000Z","updated_at":"2024-05-30T16:04:31.000Z","dependencies_parsed_at":"2022-08-29T12:12:50.555Z","dependency_job_id":null,"html_url":"https://github.com/yaqwsx/nativescript-simple-networking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaqwsx%2Fnativescript-simple-networking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaqwsx%2Fnativescript-simple-networking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaqwsx%2Fnativescript-simple-networking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaqwsx%2Fnativescript-simple-networking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaqwsx","download_url":"https://codeload.github.com/yaqwsx/nativescript-simple-networking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237877020,"owners_count":19380344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","nativescript","nativescript-plugin","network","networking"],"created_at":"2024-09-26T09:21:34.086Z","updated_at":"2025-10-23T19:30:53.543Z","avatar_url":"https://github.com/yaqwsx.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeScript Simple Networking\n\nBasic UDP and TCP sockets for NativeScript.\n\n## Supported platforms\n\n- Android (any device with Android 4.4 and higher)\n\nThere is no support for iOS (yet), as I am not an iOS developer. Contributions\nfor adding iOS support are welcome!\n\n## Installing\n\n```\ntns plugin add nativescript-simple-networking\n```\n\n## Usage\n\nThis plugin provides three classes: `UdpServer`, `TcpClient` and `TcpServer`.\nAll of them provide similar, callback-based, interface. An example of usage is\nworth a thousands words and therefore here is a TypeScript example:\n\n```js\nimport {UdpServer, TcpClient, TcpServer} from \"nativescript-simple-networking\";\nimport {Address4} from \"ip-address\";\n\nvar udpServer = new UdpServer();\nudpServer.onPacket = (sender: Address4, message: string) =\u003e {\n    console.log(\"Message from UDP: \", message);\n};\nudpServer.onError = (id: number, message: string) =\u003e {\n    console.log(\"UDP error for action #\", id, \": \", message);\n};\nudpServer.onFinished = (id: number) =\u003e {\n    console.log(\"UDP finished action #\", id);\n};\n\n// Start listening on port 33333\nvar udpConnectEvent: number = udpServer.start(33333);\nconsole.log(\"UDP start event is: \", udpConnectEvent);\n// Broadcast a message\nvar udpBroadcastEvent: number = udpServer.send(\"255.255.255.255\", \"I am alive!\");\nconsole.log(\"UDP broadcast event is: \", udpBroadcastEvent);\n\n// Start a TCP server listening on port 44444 with maximum 2 clients\nvar tcpServer = new TcpServer(2);\ntcpServer.onClient = (client: Address4) =\u003e {\n    console.log(\"New TCP client: \", client.adddress)\n    tcpServer.send(client, \"Welcome!\");\n};\ntcpServer.onData = (client: Address4, data: string) =\u003e {\n    console.log(\"New data from client \", client.address, \": \", data);\n};\ntcpServer.onError = (id: number, client: Address4, message: string) =\u003e {\n    if (client)\n        console.log(\"TCP server client error\", client.address, \": \", message);\n    else\n        console.log(\"TCP server error: \", message);\n};\ntcpServer.onFinished = (id: number) =\u003e {\n        console.log(\"TCP server finished transaction #\", id);\n};\n\ntcpServer.start(44444);\n\n// Connect to the TCP server\nvar tcpClient = new TcpClient();\ntcpClient.onData = (data: string) =\u003e {\n    console.log(\"Data from TCP client: \", data);\n};\ntcpClient.onError = (id: number, message: string) =\u003e {\n    console.log(\"TCP client error for action #\", id, \": \", message);\n};\ntcpClient.onFinished = (id: number) =\u003e {\n    console.log(\"TCP client finished action #: \", id);\n};\n\n// Connect client, action IDs are ommited in this example - see UdpServer\ntcpClient.start(\"localhost\", 44444);\ntcpClient.send(\"I am also alive!\");\n\n// When we are finished\nudpServer.stop();\ntcpServer.stop();\ntcpClient.stop();\n```\n\n## Contributing\n\nAny contributions are welcome, feel free to submit a pull request on GitHub. I\nwould appreciate a PR, which would add support for iOS.\n\n## Future Plans\n\n- support iOS\n- implement a wrapper for future-based interface\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaqwsx%2Fnativescript-simple-networking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaqwsx%2Fnativescript-simple-networking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaqwsx%2Fnativescript-simple-networking/lists"}