TCP/IP Extension

Hello everybody,

Last year, I needed a component in AI2 that did the work of a client socket. As there wasn’t any, I used Web component instead, but it didn’t do everything I need. A few days ago, I saw that there were the possibility to use extensions, but didn’t find a client socket one. I decided to make one so.

Here it is : ClientSocket extension V0.4.4.2 (Trailling 00 bug repair and timeout set release) !

Properties :

  • serverAddress (R/W)
  • serverPort (R/W)
  • timeoutms (R/W)
  • hexaStringMode (R/W)
  • connectionState (RO)
  • debugMessages (RW)

Methods :

  • Connect
  • Disconnect
  • SendData

Events :

  • DataReceived
  • RemoteConnectionClosed

Known bugs :

  • I think that only messages less than 1024 bytes work

  • If connection to server is lost (not server shutdown, but wifi connection problem by example), no events will indicate it (but crashes are now fixed :slight_smile: thx Axeley)

  • on some android devices, disconnection of the serveur is not crashing anymore the app.

If you want to send non ascii data, modify hexaStringMode to true and send data as “303132” to send characters “012”. Received data will be also hexa characters.

Timeout to server connect is 2000 ms default but can be changed.

If you want, you can use it, test it and report me suggestions and bugs.


Jean-Rodolphe Letertre
Extension : (17.7 KB)
Basic Project : TestSocket.aia (19.8 KB)


Java Source (to be reextensionned to .java … not allowed …) : ClientSocketAI2Ext.txt (17.8 KB)

Why did you remove the aix file ?

aix file is in the first post (had to create a second post to put 3 files as I’m a new(?) user), isn’t it showed to you ?

Yes, but wasn’t when I posted :wink:

Hello, being a beginner I do not understand the usefulness of this block. What is it exactly for?
Thanks for reading.

This extension is to be able to communication via the wifi network with a server at a low level state (well not so low, but just above Transport Layer …). You will then be able to send and receive information to any server by reimplementing the application layer needed.
I developed this extension to be able to communicate with the Ethernet shield of an Arduino card. I set up an TCP/IP server on the Arduino and use my extension to build an application to be the client to connect to it.
Cheers !

1 Like

Hello, I’m a new user of App Inventor and I´m having some troubles with this app. When I run it, an error apears telling me that it cannot find the component: ClientSocketAI2Ext1. Could you please help me?

This extensions still hangs up the application when you disconnect, even if debugging is set to false. Please advise.

Yes Indeed same issue here setting (ClientSocketAI2Ext1.DebugMessages to false ) has no effect , it hangs on disconnect . I would really appreciate if someone has found a fix for this issue. I am using Android version 9.1

Ok, don’t have the problem on my phone. Will try it on my wife’s one (more recent) to be able to see the problem more precisely. No ETA (estimated time of achievement) though … :-S

Hi JR, any update? I am willing to pay for the update, the extension works beautifully, apart for the disconnect.

Ok, tried to send new version to JP Le Riche, but he did not reply to me. Here is the new version, somebody can try it ? (18.2 KB)
(and why can’t I edit the first post ??)


Hi! Is there a chance to fix the 1kB limit?

It worked perfectly well. thank you.

It depends, if you need 2kB, it's easy to change, but if you need any size ... I have to make more research to know how to solve the problems involved ...

1 Like

My premilinary guess is about 6-7kByte i need, but maybe i will split ti to smaller packages. i dunno yet.
Or i send my data in definitions and let the server compose the full stream from it.

Hi Jean,
I also wants to know how I can extend the Byte size to 4K to 5K.

Ok, guys ! New version with a limit of ~100k !
Test it and tell me if there is a problem !
ClientSocketAI2Ext.aix (18.2 KB)


I am using the ClientSocketAI2Ext to connect to ESP8266 SoftAp in order to scan and connect to an SSID. When the ESP8266 actually connects to the selected SSID it momentarily turns OFF and back ON its Access Point and the app crashes.
It should just raise an event but not crash. Any ideas?