TCP server in android

Hi , I want to send some data to spark core from my android device via tcp . So can anyone tell me what should I do in android and spark module?

Hi @parthibmtr - you’ll want to use TCPServer() on the Spark Core to listen for TCP connections, get its IP address, and then open a TCP socket from Android.

Device discovery in this case can be a pain (finding the device’s IP address), and that’s where the cloud is useful; rather than setting up all the socket communications, you could just use Spark.function() to expose functions in your firmware and communicate through the Spark API:

What are you building? If you give us some more info we can make recommendations for the right way to build it.

1 Like

Thanks zach for your valuable words.
Actually I built an app on android ,it will send a string and on receive that string spark core will turn on a led. Like if i send ‘U’ then D1 led will glow. My android app is a tcp client. Latter on I will use this spark core to control a fish robot via android , so what’s your recommendation …

Hey , I got stuck in another problem…I was trying to flash the Tcpserver program that you sent me previously…do I need to include
any library when I write the TCP Server program?