SilentKiller
SilentKiller

Reputation: 6942

send & receive data through socket

i am beginner in android development. How to send images among the different android devices through sockets. i want to distribute the same image to the whole group(may be of 5 people). how to to send data or image over the sockets.

Upvotes: 2

Views: 4531

Answers (2)

Lucifer
Lucifer

Reputation: 29632

Basically you need to do Socket Connection for your requirement, Please look at here. It has very simple example of Socket Connection.

Socket Connection is basically done by using and IP and a PORT number.

Socket s = new Socket("127.0.0.0",80);

Then you can write String by using OutputStream and PrintWriter Class and same time you can read the in-coming message by using BufferedReader class.

Upvotes: 2

zaf
zaf

Reputation: 23244

There are 2 main ways you can achieve this.

Either by pulling images from another device or pushing images to devices.

You can use low level sockets or http requests to a running web server or both.

With a pure socket solution learn how to setup a socket that is listening on a port and accepts connections and sends back the images. With the client devices you need to just learn how to make a connection to another ip and port using a sockets.

There is lots of code and tutorials on the web for you to use and learn from.

Upvotes: 4

Related Questions