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.

Cheers,

Jean-Rodolphe Letertre
Extension : com.gmail.at.moicjarod.aix (17.7 KB)
Basic Project : TestSocket.aia (19.8 KB)

1 Like

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

Why did you remove the aix file ?

Hello,
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.

Hello,
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