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 7008869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:47:27+00:00 2026-05-27T21:47:27+00:00

The PC Windows is sending the confirmation. But that is not arriving to Linux.

  • 0

The PC Windows is sending the confirmation. But that is not arriving to Linux.
What am i missing? (But when i do not use Windows 7 and do the same code under Linux to Linux it works.)

Any ideas!!!

Windows 7 PC: Sender/Replyer

System.out.println("[UDP]: " 
          + "RemoteIP: " + IPAddress.toString() + " "
          + "Port: " + port + " " 
          + "Length: " + send.length() + " "
          + "Sending confirmation!"); // it shows it has correct ip, port and lenght                   
sockOutput = new DatagramPacket(send.getBytes(), send.length(), IPAddress, port);
serverSock.send(sockOutput);// is it failing???

Linux PC: Receiver/Commander

String receive = sendUDPBytes("request", ip).toString();

if (receive.length()<=0) // Waiting forever, and nothing happens LINUX.
{
    System.out.println("FAILED");
    System.exit(0);
} else {
      try {                                          
            /* JOB todo */
      } catch (Exception ex) {

      }                    
}
sockOutput.write(receive.getBytes());

public static String sendUDPBytes(String bytes, String[] ip) throws IOException
{            
    String downloaded = null;      
    DatagramSocket socket = new DatagramSocket();
    InetAddress IPAddress = InetAddress.getByName(ip[2]);

    byte[] sendData = new byte[14024];
    byte[] receiveData = new byte[14024];

    sendData = bytes.getBytes();
    DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length);
    socket.connect(IPAddress, 58889);
    if (socket.isConnected())
    {
        System.out.println("[UDP]: sending....., waiting......... until receive....");
        socket.send(sendPacket);
    }

    DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
    socket.receive(receivePacket);      
    downloaded = new String(receivePacket.getData());

    System.out.println("[UDP]: closing.....");
    socket.close();              
    return downloaded;
}

Follow up:

0) Do not get confuse with “ARE U IN A SAME SUBSET???”, so if you have /28 network all in can exchange the packet. In that case it works but that is not the case most of the time.

1) The code is perfect, when i test LAN to LAN no matter what operating system it is, it works (no firewall ofcource)

2) When i test Windows to Windows in the same PC it works too

3) When i test Linux to Linux it works too

4) When i test Linux to Windows or Windows to Linux it works too

5) The same code i put in one central server and same code i ran in local Windows PC, and other ISP seems to allow it.

6) Sp-ended 10 hours to find it

Guess:

What exactly was then the cause? Well, ISP is losing the packet that was sent to my public IP or they maybe disabling those even i have Public IP.

  • 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-27T21:47:27+00:00Added an answer on May 27, 2026 at 9:47 pm

    You are doing String bytes and getBytes() depends on the platform encoding. getBytes("UTF-8") would be explicit.

    Another thing are the differing newlines: Linux \n, Windows \r\n.

    The toString() might throw an exception if the bytes stem from Windows Latin-1 (Cp1252), and it tries to interprete them as UTF-8.


    private void test(OutputStream sockOutput, String[] ip) throws IOException {
        String receive = sendUDPBytes("request", ip);
    
        if (receive.length() <= 0) // Waiting forever, and nothing happens LINUX.
        {
            System.out.println("FAILED");
            System.exit(0);
        } else {
            try {
                /*
                 * JOB todo
                 */
            } catch (Exception ex) {
            }
        }
        sockOutput.write(receive.getBytes("UTF-8"));
    }
    
    public static String sendUDPBytes(String bytes, String[] ip) throws IOException {
        return new String(sendUDPBytesRaw(bytes.getBytes("UTF-8"), ip), "UTF-8");
    }
    
    public static byte[] sendUDPBytesRaw(byte[] sendData, String[] ip) throws IOException {
        DatagramSocket socket = new DatagramSocket();
        InetAddress IPAddress = InetAddress.getByName(ip[2]);
    
        byte[] receiveData = new byte[14024];
    
        DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length);
        socket.connect(IPAddress, 58889);
        if (socket.isConnected()) {
            System.out.println("[UDP]: sending....., waiting......... until receive....");
            socket.send(sendPacket);
        }
    
        DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
        socket.receive(receivePacket);
        byte[] downloaded = receivePacket.getData();
    
        System.out.println("[UDP]: closing.....");
        socket.close();
        return downloaded;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JNA to manipulate application windows on Linux by sending Xlib messages but
Any good alternative for Spy++ that allows sending messages to windows? Thanks
Is there any API for Windows Phone - or some other method besides sending
While logging off in Windows XP the system is sending the message with code
I have a problem sending POST request with VB6. The code below works properly
javax.comm.NoSuchPortException at javax.comm.CommPortIdentifier.getPortIdentifier sending sms(text) from java code to mobile phone in windows i
I'm starting a process in C# and then sending Windows messages to that process
I can send any windows application key strokes with PostMessage api. But I can't
Sending a mail through my windows application to a person asking him to log
I have been experimenting with sending messages from two .NET Windows Forms applications using

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.