[PAID] Client Socket Pro

πŸ‘‹ Introduction

Hi everyone, in this topic i'll introduce you to my 2nd extension:

icon Client Socket Pro

With it you can connect to a TCP server hosted within the same nework to transfer data and files (using Java's Socket class)

If you have the client already and you're in need of a server, get a look at my Server Socket Pro extension


❓ Main features

Here you can find a list containing the main features of the extension, explaining even what's different from other extensions that offer similar features

Easy and stable connection

Connect easily to any TCP socket using few blocks and customize, if needed, many options that allow you to perfectly integrate the extension in your existing environment

Multiple charsets supported

You can select the charset to use for communications according to your needs, allowing you to adapt the extension to your needs

❗Files transfer

Unlike other similar extensions, where only text data is supported, you can easily and quickly send files to the server (requires using my Server Socket Pro extension since it uses a custom protocol)

❗Advanced error handling

The extension comes with an advanced errors management and handling system, that will catch most of the errors and avoid crashes, returning a severity level to filter the errors more easily, an error tag to quickly identify the error's category and the error message


πŸ“’ Blocks and documentation

Overview

Events

Show/hide events

Error occurred

Error occurred

Fired when an error occurs

:heavy_plus_sign: Parameters:

  • severity | Integer rapresenting the severity level of the error, the highest the more severe [1-3]
  • tag | Short string useful to quickly identify the type of error (get a look at the Error tags section in this post)
  • message | Error message returned by the app

Connected

Connected

Fired when the client has connected to server

Disconnected

Disconnected

Fired when the client has disconnected from server

Message Received

Message received

Fired when the client receives a message from the server

:heavy_plus_sign: Parameters:

  • message | String containing the message

Message Sent

Message sent

Fired when the client has sent a message to the server

:heavy_plus_sign: Parameters:

  • message | String containing the message

File Sent

File sent

Fired when the client has sent a file to server

:heavy_plus_sign: Parameters:

  • fileName | String containing the file name (with extension)

File Send Progress

Fired everytime there's an update in the file's uploadto server

:heavy_plus_sign: Parameters:

  • fileName | String containing the file name (with extension)
  • sent | Long (number) indicating the amount of bytes sent
  • total | Long (number) indicating the total size of the file
  • percentComplete | Double (number) containing the current transfer completion percentage

Ping Result

Ping result

Fired after a ping has been executed

:heavy_plus_sign: Parameters:

  • connected | Boolean containing the ping result (true = connected)

Methods

Show/hide methods

Connect

Connect

Connects to the specified server with the given port

:heavy_plus_sign: Parameters:

  • hostname | String containing the server hostname (generally it's the IP)
  • port | Integer containing the port number [0-65535]

Disconnect

Disconnect

Disconnects from server

Write

Write

Writes in the socket output stream (to server), if ln = false sending not guaranteed since the EOL character is not sent

:heavy_plus_sign: Parameters:

  • message | String containing the message
  • ln | Boolean indicating whether the EOL character should be sent at the end of the message

Send File

Send file

Sends the given file to the server, note that this uses a custom protocol and requires the use of my Server Socket Pro extension (check the Protocol section in this post)

:heavy_plus_sign: Parameters:

  • filePath | String containing the full file path

Ping

Ping

Pings the server to test connection by sending the Ping Character (defined in properties), for more details check the Protocol section in this post

Is Connected

Is connected

Retrieves the client's connection status

:leftwards_arrow_with_hook: Returns:

  • boolean | true if the client is currently connected to the server. Note that this differs from ping because it only checks if the device disconnected in a graceful way, so doesn't work in limit cases or when, for example, it crashed. For that use the Ping method, that actively checks if a device is connected and responsive

Get Device Ip

Get device ip

Retrieves the client's address

:leftwards_arrow_with_hook: Returns:

  • string | the current device's IP address

Get Device Hostname

Get device hostname

Retrieves the client's hostname

:leftwards_arrow_with_hook: Returns:

  • string | containing the hostname of the current device

Properties

Show/hide properties

Connection Timeout

Connection timeout get

Maximum time (in milliseconds) the client will wait while attempting to connect to a server

:1234: Default: 15000 (ms)

Socket Timeout

Socket timeout get

Maximum time (in milliseconds) the client will wait for data to be received once a read operation is initiated on the socket

:1234: Default: 0, disabled

Ping Timeout

Ping timeout get

Maximum time (in milliseconds) the client will wait for pingback signal to be sent

:1234: Default: 5000 (ms)

Ping Char

Ping char get

Character to be sent for ping execution and protocol messages (check the Protocol section in this post). The character is defined using an integer, which is the decimal ASCII rapresentation of it

:1234: Default: 6 (ACK character)

Line Delimiter

Line delimiter get

Line end delimiter (EOL)

:1234: Default: "\n"

Charset

Charset get

Charset to use for data transmission

:1234: Default: "UTF_8" (check available types below)

Charset types

usascii

utf16

utf8

Charset name constants



❌ Error tags

As specified in the main features, this extension provides a complete and efficient errors management system, here you can find a resume of all the possible error tags with their severity and description

Show/hide errors

CONNECTION

[3] CONNECT_ERROR: generic connection error (Exception)
[3] CONNECT_ERROR_IO: error while creating ClientSocket or during IO operations (IOException)
[3] CONNECT_ERROR_HOST_UNKNOWN: host unknown, unable to connect (UnknownHostException)
[3] CONNECT_ERROR_NO_ROUTE: host unreachable, unable to connect (NoRouteToHostException)
[3] CONNECT_ERROR_INVALID_PORT: port number must be between 0 and 65535
[3] CONNECT_ERROR_REFUSED: connection has been refused (ConnectException)
[3] CONNECT_ERROR_TIMEOUT: connection timeout (SocketTimeoutException)
[2] CONNECT_ERROR_ALREADY_CONNECTED: tried to connect while being already connected to a server

DISCONNECTION

[3] DISCONNECT_ERROR: generic error occurred during disconnection (Exception)
[3] DISCONNECT_ERROR_IO: unable to disconnect due to an IO error (IOException)
[2] DISCONNECT_ERROR_NOT_CONNECTED: tried to disconnect while not being connected to any server
[2] SERVER_DISCONNECTED: triggered when the server is no longer reachable/responsive (e.g. crashed)

OPERATIONS

[1/2] ERROR_NOT_CONNECTED: tried to perform an operation without being connected to a server
[3] WRITE_ERROR: error while writing to output stream (Exception)
[3] WRITE_ERROR_FILE: generic error occurred while writing to socket (Exception)
[3] WRITE_ERROR_FILE_IO: error while writing to output stream (IOException)
[3] WRITE_ERROR_UNAVAILABLE: Socket output stream unavailable
[3] WRITE_ERROR_NO_FILE: file does not exist or is not accessible
[2] ERROR_SENDING_IN_PROGRESS: tried to perform an operation while a file transfer was in progress
[3] PINGBACK_ERROR_UNAVAILABLE: Socket output stream unavailable, fired while replying to server's ping
[3] PINGBACK_ERROR: error while writing to output stream, fired while replying to server's ping (Exception)
[3] PING_ERROR: error while performing connection test (Exception)
[2] PING_ERROR_ALREADY_WAITING: tried performing a ping while another was pending
[3] MESSAGE_READ_ERROR: error while reading incoming data (IOException)
[3] LISTENER_ERROR: generic error while crating listener/reading data (Exception)

PROPERTIES

[2] INVALID_PROPERTY: invalid property value provided
[2] CHARSET_ILLEGAL: illegal charset name provided (IllegalCharsetNameException)
[2] CHARSET_INVALID: provided charset is not valid, might be null, empty or not supported by the current device (IllegalArgumentException)
[2] CHARSET_ERROR: generic charset error (Exception)
[2] PROPERTY_BLOCK: tried to change a property while connected to a server
[2] ERROR_IP_ADDRESS: unable to retrieve device's IP address


πŸ“œ Protocol

The extension implements a custom protocol to ping devices and perform file transfers, here's an explaination of how it works, to avoid conflicts with custom logics or external extensions. On the base of the protocol there's the "Ping Char" which, by default, if the ACK character (dec 6 in ASCII table). This character is used how it follows:

Show/hide protocol description
  • PING REQUEST,
    Sent 1 time from client to server to request a pingback, happens when the Ping method is executed

  • PINGBACK
    Sent 2 times from the server to the client in response to a ping request

  • FILE TRANSFER START
    Sent 3 times from the client to the server to denote that a file transfer is going to happen, right after it the client sends files info to the server (e.g. file name, size...) and then waits for the file transfer ready signal from the server before starting to send the actual file

  • FILE TRANSFER READY
    Sent 3 times from the server to the client after it has received from the client the file's info, denotes that the server is ready to read the file's bytes and that the actual transfer can start



πŸ’Έ Pricing and download

In the initial phase the extension will be paid, but i plan on making it free after a while, if i see that many people are interested in it and supported me for my workπŸ˜†

Minimum donation: $15.00 (you can donate more if you appreciate my work!)
Includes: ClientSocketPro extension (.aix file, version 1.0, 2024-03-13T23:00:00Z)
License : license.pdf (51.4 KB) (51.1 KB)

Please contact me in DM before buying

Payment methods:

PayPal
Revolut

If you plan on buying my "ServerSocket Pro" extension as well, contact me to receive a bundle offer and save something!


Thanks to @shreyash and his tool Rush that i used to build the extension!

3 Likes