简体   繁体   中英

Listening a particular port on linux to access data comes from mobile device

i am newbie to Linux platform, i am working on java technology. what i have to do is : Having a program that running on mobile devices,that sends some data to my Linux machine, now i have to create a program in java that

  1. listen to a particular port.
  2. access data comes on that port(which is sending by mobile device)
  3. save that data to the database.
  4. response back to the mobile device.

ie i would make my Linux system as server that can listen from many clients(mobile devices), but not getting how to configure this environment... :(

i used cent OS 5.4 and installed jdk1.6.0_24

any help would be appreciated.....

thanx in advance!

khushi

One of Java's greatest strengths is that you can pretty much ignore the host operating system as long as you stick to core Java features. In the case you're describing, you should be able to accomplish everything by simply using the standard Java networking APIs and either the JDBC to access an existing, external database or you could choose any number of embedded Java databases such as Derby . For your stated use case, that you'll be running the application on Linux is pretty much irrelevant (which should be good news... you don't need to learn a whole operating system in addition to writing your app ;-).

Here's a nice client/server tutorial , in that it is broken into steps, and adds each new concept in another step.

Here's another client/server tutorial with much more detail.

I would write it to accept one connection at a time. Once that works, I would study the new(ish) java.lang.concurrent classes, in particular the ExecutorService, as a way of managing the worker bee handling each connection. Then change your program to handle multiple connections using those classes. Breaking it up in two steps like that will be a lot easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM