/** Clientsocket Communication Class **/
public class Clientsocket {
/** server address */ private String serverurl= "192.168.124.214"; /** server port */ private int serverport=8888; /* Send command thread */ class Sendcommandthread extends thread{ &N Bsp private string command; public sendcommandthread (string acommand) { & nbsp This.command = acommand; } public void run () { &N Bsp try{ socket socket = new Socket (ServerURL , ServerPort); printwriter out = new PrintWriter (socket.getoutputstr EAM ()); out.print (command); out.flush (); }catch (unknownhostexception e) { &N Bsp } catch (IOException E) { } } } /** send file thread **/ class Sendfilethread extends thread{ private byte bytebuffer[] = NE W byte[1024]; Private outputstream outsocket; Private BYTEARRAYOUTPU TStream myoutputstream; public sendfilethread (Bytearrayoutputstream myoutputstream) { This.myoutputstream = myoutputstream; try {&NB Sp myoutputstream.close (); } catch (IOException e) { e.printstacktrace (); }&N Bsp } public void run () { try {&NBSp SOCKET socket = new Socket (serverurl,serverport); &NB Sp Outsocket = Socket.getoutputstream (); // Write header information string msg = Java.net.URLEncoder.encode ("Phonevideo", "Utf-8" ); byte[] buffer = msg.getbytes (); &NBSP ; outsocket.write (buffer); Bytearrayinputstream InputStream = new Bytearrayinputstream (Myoutputstream.tobytearray ()); &N Bsp int amount; while ((Amount = Inputstream.read (bytebuffer))! =-1) {& nbsp Outsocket.write (bytebuffer,0,amount); & nbsp   } Myoutputstream.flush (); myoutputstream.close (); SOCKET.C Lose (); } catch (IOException e) { E.printstacktrace (); } } & nbsp }}
Android Socket Communication (client) Send data