Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4321688
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:46:40+00:00 2026-05-21T08:46:40+00:00

My Android app sends/retrieves data to/from the user’s own PC using HTTP and it’s

  • 0

My Android app sends/retrieves data to/from the user’s own PC using HTTP and it’s working fine with a handful of beta testers. I now need to consider a situation where the PC is hibernating.

I’ve never done this before but I’ve googled to find info about the WOL ‘magic packet’ and some simple source written in C (using CAsyncSocket at the client end). Doing this over a wi-fi connection on the user’s home network is likely to be relatively straight-forward but ideally I want this to work over mobile internet (assuming the user can configure their home router to accept / forward the packet).

I’m guessing I need to use some generic Java network code and I’ve been looking at java.net.

At this point I can’t decide whether I should be using java.net.Socket or java.net.DatagramSocket. So the question is, am I approaching this the right way and which of the two socket types should I be using (or would both suffice)? Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:46:40+00:00Added an answer on May 21, 2026 at 8:46 am

    Here is some C# code that I have used in the past. It should be relatively easy to convert into java and send using a DatagramPacket

    namespace WakeOnLan
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                byte[] mac = new byte[] { mac address goes here i.e 0x00, and so on };
                WakeUp(mac);
            }
    
            private static void WakeUp(byte[] mac)
            {
                //
                // WOL packet is sent over UDP 255.255.255.0:40000.
                //
                Console.WriteLine("Waking Up.......");
                UdpClient client = new UdpClient();
                client.Connect(IPAddress.Broadcast, 40000);
    
                //
                // WOL packet contains a 6-bytes trailer and 16 times a 6-bytes sequence containing the MAC address.
                //
                byte[] packet = new byte[17 * 6];
    
                //
                // Trailer of 6 times 0xFF.
                //
                for (int i = 0; i < 6; i++)
                    packet[i] = 0xFF;
    
                //
                // Body of magic packet contains 16 times the MAC address.
                //
                for (int i = 1; i <= 16; i++)
                    for (int j = 0; j < 6; j++)
                        packet[i * 6 + j] = mac[j];
    
                //
                // Submit WOL packet.
                //
                client.Send(packet, packet.Length);
                Console.WriteLine("Machine Woke Up....");
            }
        }
    }
    

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using eclipse to develo[p an Android app. the app sends the user name
I have an Android app that fetches data from the web service using ksoap2,
My android app sends data to a servlet every 10 seconds. the servlet receives
I'm sending data from an Android app to a php script which recieves the
I'm trying to get the basics of an Android app that sends and receives
I'm trying to create an app for Android that simply sends a command to
The android app reads from database but doesnt write anything to DB, the app
I would like to make an app on android which sends MIDI messages over
I've created this android app that sends onTouchEvents points to a web server, and
What is the appropriate way to implement a location-based Android app that periodically sends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.