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 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-tcp-client-android

v0.0.5

Published

一个用于 Android 平台的 Capacitor TCP 客户端插件。

Downloads

7

Readme

Capacitor TCP Client Android

A Capacitor plugin for TCP client functionality on Android platform.

一个用于 Android 平台的 Capacitor TCP 客户端插件。

Installation | 安装

npm install capacitor-tcp-client-android

Usage | 使用方法

import { TcpClient } from 'capacitor-tcp-client-android';

// Connect to a TCP server
// 连接到 TCP 服务器
const result = await TcpClient.connect({
  ip: '127.0.0.1',
  port: 8080
});

// Send data once
// 发送一次数据
await TcpClient.sendOnce({
  connect_id: result.connect_id,
  data: 'Hello, Server!'
});

// Keep sending data
// 持续发送数据
await TcpClient.keepSend({
  connect_id: result.connect_id,
  data: 'Hello, Server!',
  duration: 1000 // 发送间隔,单位毫秒
});

// Stop sending data
// 停止发送数据
await TcpClient.stopSend({
  connect_id: result.connect_id
});

// Disconnect
// 断开连接
await TcpClient.disconnect({
  connect_id: result.connect_id
});

// Add listeners
// 添加监听器
TcpClient.addListener('onData', (data) => {
  console.log('Received data:', data);
});

TcpClient.addListener('onConnectStateChange', (state) => {
  console.log('Connection state changed:', state);
});

API | 接口说明

connect(options: TCPClientConnectOpt): Promise

Connect to a TCP server.

连接到 TCP 服务器。

参数说明:

  • ip: 服务器 IP 地址
  • port: 服务器端口号

返回值:

  • connect_id: 连接 ID,用于后续操作
  • connected: 连接状态
  • data: 连接信息

sendOnce(options: TCPClientSendOnceOpt): Promise

Send data once to the connected server.

向已连接的服务器发送一次数据。

参数说明:

  • connect_id: 连接 ID
  • data: 要发送的数据内容

返回值:

  • connect_id: 连接 ID,用于后续操作
  • success: 是否发送成功
  • message: 发送结果描述

keepSend(options: TCPClientKeepSendOpt): Promise

Keep sending data to the connected server at specified intervals.

以指定间隔持续向服务器发送数据。

参数说明:

  • connect_id: 连接 ID
  • data: 要发送的数据内容
  • duration: 发送间隔时间(毫秒),可选参数

stopSend(options: TCPClientStopSendOpt): Promise

Stop the continuous sending of data.

停止持续发送数据。

参数说明:

  • connect_id: 连接 ID

disconnect(options: TCPClientDisconnectOpt): Promise

Disconnect from the server.

断开与服务器的连接。

参数说明:

  • connect_id: 连接 ID

addListener(eventName: 'onData', listenerFunc: (data: TCPClientDataEvent) => void): Promise

Add a listener for data events.

添加数据事件监听器。

addListener(eventName: 'onConnectStateChange', listenerFunc: (data: TCPClientStateOpt) => void): Promise

Add a listener for connection state changes.

添加连接状态变化监听器。

Features | 特性

  • 支持 TCP 连接建立和断开
  • 支持单次发送和持续发送数据
  • 支持自动重连机制
  • 支持多连接管理
  • 支持心跳检测
  • 支持自定义发送间隔
  • 支持事件监听

License | 许可证

MIT

Author | 作者

GaliGG_CC