I need a little bit help regarding to android socket programming. I had made a server-client prototype using java socket programming. In server client scenario , I am sending commands from 1-10 and sever do some task according to command received from client. e.g. when server receives a command it sever will send a bufferedImage to the client. Its (java prototype) is working fine. In this scenario, both server and client a java desktop applications, Now I want to make android as a client. Can someone help me in this regard or suggest me good resources of android socket programming?
(Please note BufferedImage class is not supported by Android.)
Most current network programming is done either using sockets directly, or using various other layers on top of sockets.
The first step is to install the Java Socket.IO client with Gradle. We must remember adding the internet permission to AndroidManifest. xml . Now we can use Socket.IO on Android!
A socket is a communications connection point (endpoint) that you can name and address in a network. Socket programming shows how to use socket APIs to establish communication links between remote and local processes.
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); After the creation of the socket, the bind function binds the socket to the address and port number specified in addr(custom data structure). In the example code, we bind the server to the localhost, hence we use INADDR_ANY to specify the IP address.
There is no problem in porting your application. Android runs on Java, which very similar to desktop version. All you need is to migrate BufferedImage
to simple byte array, and to use ImageIO
on your server side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With