Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Socket client node js server

I am creating an android client using socket not by Socket.io and node js is the server.
I need to know answers for this.

1.It is possible that i have asked?
2.Can socket.io can be implemented as an android client?
3.If socket.io not available, then show how to implement this by socket?
4.If possible then show how to implement?

like image 492
ImMathan Avatar asked Feb 13 '26 09:02

ImMathan


2 Answers

One of the best solutions is to use socket.io-java-client which is fully android supported.

EDIT: If you're using socket.io 1 or later then use nkzawa socket.io-client.java

like image 51
M Omayr Avatar answered Feb 15 '26 23:02

M Omayr


This is a tutorial I made to make communicate your Android with a Node.js server:

(without any additional library)

https://causeyourestuck.io/2016/04/27/node-js-android-tcpip/

This is a foretaste of how it looks like at the end:

Client socket = new Client("192.168.0.8", 1234);
socket.setOnEventOccurred(new Client.OnEventOccurred() {
    @Override
    public void onMessage(String message) {
    }

    @Override
    public void onConnected(Socket socket) {
        socket.send("Hello World!");
        socket.disconnect();
    }

    @Override
    public void onDisconnected(Socket socket, String message) {
    }
});

socket.connect();
like image 25
Omar Aflak Avatar answered Feb 16 '26 00:02

Omar Aflak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!