Results 1 to 2 of 2
  1. #1
    Andrew121 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default UDP Broadcast receiving

    Hello, I've been googling and trying out a solution for hours now. I have an application on a different computer connected to a router. This app sends udp broadcasts on a specific port on the address 255.255.255.255. The other application which is the one I'm making is in java and needs to receive this broadcast. I have tried several times to make this work without success. Here is my progress if it helps:
    Java Code:
    		new Thread() {
    			public void run() {
    
    				try {
    					int port = 8094;
    					DatagramSocket dsocket = new DatagramSocket(port);
    					byte[] buffer = new byte[2048];
    
    					DatagramPacket packet = new DatagramPacket(buffer,
    						buffer.length);
    					while (true) {
    						System.out.println("Receiving...");
    						dsocket.receive(packet);
    						String msg = new String(buffer, 0, packet.getLength());
    						System.out.println(packet.getAddress().getHostName()
    								+ ": " + msg);
    						packet.setLength(buffer.length);
    					}
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		}.start();
    Thanks in advance

  2. #2
    Andrew121 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default

    solved, I had the wrong port -_- I'll leave this up for anyone that wants to use it.

Similar Threads

  1. Accept Connect Request and Read Broadcast
    By lockcompetition in forum Networking
    Replies: 2
    Last Post: 03-28-2010, 04:43 AM
  2. Receiving Message in J2ME
    By java girl in forum CLDC and MIDP
    Replies: 2
    Last Post: 10-27-2009, 06:49 AM
  3. fake ARP broadcast packet
    By junkredish in forum Networking
    Replies: 0
    Last Post: 09-06-2008, 07:01 PM
  4. Receiving UDP pockets
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 09:08 PM
  5. broadcast messaging
    By bhanu in forum Networking
    Replies: 1
    Last Post: 10-30-2007, 12:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •