Skip to content

An UDP Server for Android and Linux that allows interconection.

License

Notifications You must be signed in to change notification settings

DGMonkeyKing/UDP-Server-Android_Linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#UDP Server for Android and Linux This is an UDP Server that allows to connect Linux and Android via IP direction. In this case, I going to show you how to stablish the Android device as the host and the Linux device as the guest

##First of all... First thing you must do is to download or to clone this project. There are 2 .c files:

  • modlist.c file is used as an example for the P2P connection. Within the Makefile, this code generate a .ko file (a module for the kernel) which will interact with the host application.
  • servUDPmod.c file is the server itself. With the proper compilation can be used in Android architecture x86 or in Linux.

##Compilation For develope this app, I used a Virtual Machine with Android x86 and Linux Debian 7. I also used Android NDK to compile

Once you have the project in your PC, use the make directive to compile the module and the gcc compilator to compile the host aplication for Android.

  • Host application (Android)

    gcc -m32 -static -g -Wall servUDPmod.c -o udp-android

  • Host application (Linux)

    gcc -o udp servUDPmod.c

The result should be something like this:

##Connecting with Android You must know the IP of your Android device. With a shell bash emulator and with the command ip addr show you can know your IP address:

Once you have the IP, connect to the Android device with adb command utility of Linux (If your trying to connect 2 Linux devices this step won't be neccesary, just skip it)

We need to connect to the IP address of the Android machine and become the superuser as I do in the image above. Once we have the superuser permissions, a re-connect must be done.

With adb push <file> <path> I copy the file to the path specified in the Android file system.

##Running With adb shell we take control of the shell of Android. Go to the path where you copied the files and then load the module modlist.ko with the command insmod <module>.

Is time to run the host and the guest application.

In the Linux device, run this command on the shell to execute the guest:

nc -u <IP address> <port> - EJ: nc -u 192.168.21.131 3000

In the Android device, run the udp-android on the shell to execute the host:

./udp-android <IP address> <port> - EJ: ./udp-android 192.168.21.131 3000

And know just write the command in the guest application. The commands allowed (at this moment) are:

  • add (int) = Adds an element in /proc/multilist/default
  • remove (int) = Remove an element in /proc/multilist/default
  • cleanup = Remove all the elements in /proc/multilist/default
  • create (string) = Create a new entry on /proc/multilist called string
  • delete (string) = Delete an old entry on /proc/multilist called string

Now to know what has been load in the /proc module just execute this command:

cat /proc/multilist/default

##License All rights reserved 2016

About

An UDP Server for Android and Linux that allows interconection.

Resources

License

Stars

Watchers

Forks

Packages

No packages published