0

I ve built an android application that shares files from mobile to pc over wifi. To initiate the sharing, i need to run socket programming server code in my pc.

Is there any way to run the server code remotely through my android device?

  • A server written in java listening to a socket can be wrapped as operating system service, and hence automatically running. – Joop Eggen Sep 12 '17 at 10:06
  • So it basically runs the whole time. Is there any other way around? Like we send a request packet to the pc and the os starts the process? – Bch Charan Sep 12 '17 at 10:42
  • Something similar to wake-on-lan feature? – Bch Charan Sep 12 '17 at 10:48
  • The running loop will consist of a server socket _wait_, hence not costing CPU when idle. For Windows I do not know of any easy services though there might be. For a running Linux, one could make a remove shell connection. Maybe e-mail? – Joop Eggen Sep 12 '17 at 10:51
  • Is there any way similar to wake-on-lan feature? If not then, how to notify the server program while its in wait state? – Bch Charan Sep 12 '17 at 11:15
  • `ServerSocket serverSocket = new ServerSocket(portNumber); Socket s = serverSocket.accept();` will wait till communication happens on that port. The operating system will accept communication on that port (firewall!) and trigger the application listening/waiting on that port. – Joop Eggen Sep 12 '17 at 11:21
  • Thanks! I'll try it! And is there any other way? – Bch Charan Sep 12 '17 at 11:25
  • It is not wifi. E-mails seem to me the easiest. Or storing them in the sky and then periodically fetching them on the server. More productive. – Joop Eggen Sep 12 '17 at 11:29
  • Have you heard of Wake-on-LAN feature? Like we can send a network message to turn on a computer? Is there any such way? Thanks anyways! – Bch Charan Sep 12 '17 at 11:30
  • There is, but having no experience... – Joop Eggen Sep 12 '17 at 11:31
  • Can i make my program a Window System service without installing third party applications such as Java Wrapper Application? – Bch Charan Sep 13 '17 at 05:22
  • Java 8's javapackager seems to be usable, see https://stackoverflow.com/questions/68113/how-to-create-a-windows-service-from-java-app – Joop Eggen Sep 13 '17 at 06:35
  • I ve no experience with javapackager.. so can you elaborate a bit? I mean, how to add javapackager to my code and how to make that code a window service? – Bch Charan Sep 13 '17 at 08:46
  • Sorry javapackager is new for me too. – Joop Eggen Sep 13 '17 at 08:55
  • Can you say, what a javapackager is? I ve googled.. but couldn't understand a bit.. – Bch Charan Sep 13 '17 at 09:03
  • https://docs.oracle.com/javase/tutorial/deployment/selfContainedApps/index.html explains it and gives a hands-on tutorial. The earlier link for usage as a service. – Joop Eggen Sep 13 '17 at 09:06
  • Suppose i ve developed an application using javapackager and generated .exe file. Now, if i share the application to other pc, does the program run as a Window service in that pc too? – Bch Charan Sep 13 '17 at 09:55

0 Answers0