java - Forwarding data from one client to another using server -
i creating android application uses wifi direct transfer data. able send data client server. want send data 1 client client through server. let suppose there 2 clients , c , server b. want send data c through b. there possible way achieve task. 1 thing had heard forward data input stream of 1 socket ouput stream of another. can please me out this.
` protected string doinbackground(void... params) { try { serversocket serversocket = new serversocket(8988); log.d(wifidirectactivity.tag, "server: socket opened"); socket client = serversocket.accept(); log.d(wifidirectactivity.tag, "server: connection done"); final file f = new file(environment.getexternalstoragedirectory() + "/" + context.getpackagename() + "/wifip2pshared-" + system.currenttimemillis() + ".jpg"); file dirs = new file(f.getparent()); if (!dirs.exists()) dirs.mkdirs(); f.createnewfile(); log.d(wifidirectactivity.tag, "server: copying files " + f.tostring()); inputstream inputstream = client.getinputstream(); copyfile(inputstream, new fileoutputstream(f)); serversocket.close(); return f.getabsolutepath(); } catch (ioexception e) { log.e(wifidirectactivity.tag, e.getmessage()); return null; } }`
Comments
Post a Comment