Ionic - Getting started with tcp sockets

Hi There,

im getting started with ionic right now, everything so far works fine. Now im trying to write a test app to dive deeper into that all.

I have a tcp socket i want to send a command and this sends me a son reply. How can i get this working? I already read about https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-socket and https://github.com/blocshop/sockets-for-cordova but im really lost to get this started.

Anyone here who can get me some help with this?

Kind regards, Christian

If you need tcp connection maybe you can try with this plugin: https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp

Hi Fabio,

this is what i already found. I saw your posts about using that too. Right now to be honest i have no clue how to integrate this into an ionic app. Are there any examples for index.html and app.js with which i can start?

Regards, Christian

I still writing this app… as soon as I have a slice of time, I’ll prepare a tutorial on using tcp…

Can you perhaps only show your relevant snippets about using the plugin here? Would be really a great help as i really want to start getting deeper into the ionic development.

No one? Still can’t get it working…

I’ve post some demo code for the community :smile:

1 Like

Hi Fabio,

thanks for your example. Gives some little hint. Doesn’t seem to work in IOS though :frowning: Perhaps i can track this down.

I’ve tested the example only on android for now…

A note from the author: “it’s entirely possible that a packet of data gets broken up into multiple packets over the network, and you need to call receive until you have it all.”

Hello. Has anyone by any chance either converted Fabio’s example or otherwise used cordova-plugin-chrome-apps-sockets-tcp in ionic 2?

Thanks

For anyone interested: the reference to the plugin is made via window, but not through the plugins namespace, but directly. Thus, in order to call, for instance, the create method, one should use:
(<any>window).chrome.tcp.socket.create();

I hope this helps someone.