π Introduction
Hi everyone, in this topic i'll introduce you to my 2nd extension: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 featuresEasy 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
Fired when an error occurs
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
Fired when the client has connected to server
Disconnected
Fired when the client has disconnected from server
Message Received
Fired when the client receives a message from the server
Parameters:
message
| String containing the message
Message Sent
Fired when the client has sent a message to the server
Parameters:
message
| String containing the message
File Sent
Fired when the client has sent a file to server
Parameters:
fileName
| String containing the file name (with extension)
File Send Progress
Fired everytime there's an update in the file's uploadto server
Parameters:
fileName
| String containing the file name (with extension)sent
| Long (number) indicating the amount of bytes senttotal
| Long (number) indicating the total size of the filepercentComplete
| Double (number) containing the current transfer completion percentage
Ping Result
Fired after a ping has been executed
Parameters:
connected
| Boolean containing the ping result (true = connected)
Methods
Show/hide methods
Connect
Connects to the specified server with the given port
Parameters:
hostname
| String containing the server hostname (generally it's the IP)port
| Integer containing the port number [0-65535]
Disconnect
Disconnects from server
Write
Writes in the socket output stream (to server), if ln = false sending not guaranteed since the EOL character is not sent
Parameters:
message
| String containing the messageln
| Boolean indicating whether the EOL character should be sent at the end of the message
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)
Parameters:
filePath
| String containing the full file path
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
Retrieves the client's connection status
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
Retrieves the client's address
Returns:
string
| the current device's IP address
Get Device Hostname
Retrieves the client's hostname
Returns:
string
| containing the hostname of the current device
Properties
Show/hide properties
Connection Timeout
Maximum time (in milliseconds) the client will wait while attempting to connect to a server
Default: 15000 (ms)
Socket Timeout
Maximum time (in milliseconds) the client will wait for data to be received once a read operation is initiated on the socket
Default: 0, disabled
Ping Timeout
Maximum time (in milliseconds) the client will wait for pingback signal to be sent
Default: 5000 (ms)
Ping Char
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
Default: 6 (ACK character)
Line Delimiter
Line end delimiter (EOL)
Default: "\n"
Charset
Charset to use for data transmission
Default: "UTF_8" (check available types below)
Charset types
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!