{"id":24385605,"url":"https://github.com/yesprasoon/capacitor-tcp-socket-manager","last_synced_at":"2026-02-18T17:03:04.894Z","repository":{"id":271206167,"uuid":"912416964","full_name":"yesprasoon/capacitor-tcp-socket-manager","owner":"yesprasoon","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-10T06:21:16.000Z","size":136,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-17T13:25:16.836Z","etag":null,"topics":["android","capacitor","hybrid-apps","ionic","networking","plugin","socket","tcp"],"latest_commit_sha":null,"homepage":"","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/yesprasoon.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-05T14:17:56.000Z","updated_at":"2025-10-10T06:21:20.000Z","dependencies_parsed_at":"2025-01-06T09:29:59.124Z","dependency_job_id":"277e71d4-1771-4d47-9a92-7a80119ffc6d","html_url":"https://github.com/yesprasoon/capacitor-tcp-socket-manager","commit_stats":null,"previous_names":["yesprasoon/capacitor-tcp-socket-manager"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yesprasoon/capacitor-tcp-socket-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesprasoon%2Fcapacitor-tcp-socket-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesprasoon%2Fcapacitor-tcp-socket-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesprasoon%2Fcapacitor-tcp-socket-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesprasoon%2Fcapacitor-tcp-socket-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yesprasoon","download_url":"https://codeload.github.com/yesprasoon/capacitor-tcp-socket-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesprasoon%2Fcapacitor-tcp-socket-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29587066,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T16:55:40.614Z","status":"ssl_error","status_checked_at":"2026-02-18T16:55:37.558Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","capacitor","hybrid-apps","ionic","networking","plugin","socket","tcp"],"created_at":"2025-01-19T11:19:35.611Z","updated_at":"2026-02-18T17:03:04.808Z","avatar_url":"https://github.com/yesprasoon.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Capacitor TCP Socket Manager\n\n`capacitor-tcp-socket-manager` is an **Android-specific** Capacitor plugin that enables seamless TCP socket communication for your hybrid mobile apps. It allows you to create a TCP server, manage client connections, send and receive messages, and handle various socket operations efficiently. **Note: This plugin currently supports Android only.**\n\n---\n\n![npm](https://img.shields.io/npm/v/@yesprasoon/capacitor-tcp-socket-manager)\n![npm downloads](https://img.shields.io/npm/dw/@yesprasoon/capacitor-tcp-socket-manager)\n![license](https://img.shields.io/github/license/yesprasoon/capacitor-tcp-socket-manager)\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [API Methods](#api-methods)\n  - [Server-Side Methods](#server-side-methods)\n    - [startServer](#startserver)\n    - [stopServer](#stopserver)\n    - [getClientCount](#getclientcount)\n  - [Client-Side Methods](#client-side-methods)\n    - [connectToServer](#connecttoserver)\n    - [disconnectFromServer](#disconnectfromserver)\n    - [sendMessageToServer](#sendmessagetoserver)\n- [Events](#events)\n  - [receiveMessage](#receivemessage)\n- [Example Usage](#example-usage)\n  - [Starting a Server](#starting-a-server)\n  - [Sending a Message from Client to Server](#sending-a-message-from-client-to-server)\n- [Planned Features](#planned-features)\n- [Troubleshooting](#troubleshooting)\n- [License](#license)\n\n---\n\n## Features\n\n- Start and stop a TCP server.\n- Connect to a TCP server as a client.\n- Send and receive messages.\n- Manage multiple client connections.\n- Get the local device's IP address.\n- Limit maximum client connections (default is 10).\n- Disconnect individual or all clients gracefully.\n\n---\n\n## Installation\n\n### Prerequisites\n- Capacitor 4 or later\n- Android Studio installed and configured\n- Node.js and npm installed\n\n### Steps\n1. Install the plugin:\n\n   For Capacitor 7:\n   ```bash\n   npm install @yesprasoon/capacitor-tcp-socket-manager\n   ```\n   For Capacitor 6:\n   ```bash\n   npm install @yesprasoon/capacitor-tcp-socket-manager@^1.1.2\n   ```\n2. Sync with Capacitor:\n   ```bash\n   npx cap sync\n   ```\n3. Rebuild the Android project:\n   ```bash\n   npx cap open android\n   ```\n\n---\n\n## API Methods\n\n### Server-Side Methods\n\n#### `startServer`\nStarts a TCP server on the specified port.\n\n**Parameters:**\n- `port`: (optional, default: 8080) Port number to start the server on.\n\n**Returns:**\n- `ipAddress`: The IP address of the server.\n- `port`: The port on which the server is running.\n\n**Usage:**\n```javascript\nTcpSocketManager.startServer({ port: 8080 })\n  .then(response =\u003e console.log(`Server started on ${response.ipAddress}:${response.port}`))\n  .catch(error =\u003e console.error(error));\n```\n\n#### `stopServer`\nStops the TCP server if running.\n\n**Usage:**\n```javascript\nTcpSocketManager.stopServer()\n  .then(() =\u003e console.log('Server stopped'))\n  .catch(error =\u003e console.error(error));\n```\n\n#### `getClientCount`\nGets the number of currently connected clients.\n\n**Returns:**\n- `count`: The number of connected clients.\n\n**Usage:**\n```javascript\nTcpSocketManager.getClientCount()\n  .then(result =\u003e console.log(`Connected clients: ${result.count}`))\n  .catch(error =\u003e console.error(error));\n```\n\n### Client-Side Methods\n\n#### `connectToServer`\nConnects to a TCP server.\n\n**Parameters:**\n- `ipAddress`: The IP address of the server.\n- `port`: (optional, default: 8080) Port number of the server.\n\n**Usage:**\n```javascript\nTcpSocketManager.connectToServer({ ipAddress: '192.168.0.100', port: 8080 })\n  .then(() =\u003e console.log('Connected to server'))\n  .catch(error =\u003e console.error(error));\n```\n\n#### `disconnectFromServer`\nDisconnects from the connected server.\n\n**Usage:**\n```javascript\nTcpSocketManager.disconnectFromServer()\n  .then(() =\u003e console.log('Disconnected from server'))\n  .catch(error =\u003e console.error(error));\n```\n\n#### `sendMessageToServer`\nSends a message to the connected server.\n\n**Parameters:**\n- `message`: The message string to send.\n- `ipAddress`: (optional): The IP address of the server. If not provided, the stored IP address (from the connection step) will be used.\n- `port`: (optional, default: 8080): Port number of the server. If not provided, the stored port (from the connection step) will be used.\n\n**Usage:**\n```javascript\nTcpSocketManager.sendMessageToServer({ message: 'Hello Server!' })\n  .then(() =\u003e console.log('Message sent successfully'))\n  .catch(error =\u003e console.error('Failed to send message:', error));\n```\n\n---\n\n## Events\n\n### `receiveMessage`\nListens for incoming messages on the server.\n\n**Usage:**\n```javascript\nTcpSocketManager.addListener('receiveMessage', data =\u003e {\n  console.log(`Message received: ${data.message}`);\n});\n```\n\n---\n\n## Example Usage\n\n### Starting a Server\n```javascript\nTcpSocketManager.startServer({ port: 8080 })\n  .then(response =\u003e console.log(`Server is running on ${response.ipAddress}:${response.port}`))\n  .catch(error =\u003e console.error(error));\n```\n\n### Sending a Message from Client to Server\n```javascript\nTcpSocketManager.connectToServer({ ipAddress: '192.168.0.100', port: 8080 })\n  .then(() =\u003e {\n    return TcpSocketManager.sendMessageToServer({ message: 'Hello, Server!' });\n  })\n  .then(() =\u003e console.log('Message sent to server'))\n  .catch(error =\u003e console.error(error));\n```\n\n---\n\n## Planned Features\n\nWe are continuously improving this plugin. Future updates may include:\n- TLS/SSL communication for secure connections.\n- IP whitelisting for enhanced access control.\n- Client authentication mechanisms.\n- Message acknowledgment for reliable communication.\n- Automatic client reconnection.\n\nAll suggestions are welcome!\n\n---\n\n## Troubleshooting\n\n### Problem: Server does not start\n- Ensure the port is not already in use by another application.\n- Check for sufficient permissions in your app's AndroidManifest.xml.\n\n### Problem: Unable to connect to the server\n- Verify the IP address and port are correct.\n- Ensure the device is on the same network as the server.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesprasoon%2Fcapacitor-tcp-socket-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyesprasoon%2Fcapacitor-tcp-socket-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesprasoon%2Fcapacitor-tcp-socket-manager/lists"}