Results 1 to 3 of 3
- 04-30-2011, 05:41 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
Problem reciving UDP Packets on Linux
Hello i made a simple code to test a program that i was doing.
The code is here:
Well this is a simple code the only think it does it's to send a udp packet to a server and server will respond.Java Code:. . . public static final byte precond[] = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; public static final byte aftercond[] = {(byte) 0x0a,(byte) 0x00}; String msg = new String(precond) + "challenge rcon" + new String(aftercond); String aux = ""; //Enviar DatagramSocket sc2 = new DatagramSocket(27020); //sc2.setSoTimeout(5000); DatagramPacket pkt = new DatagramPacket(msg.getBytes(),msg.length(),InetAddress.getByName("82.102.15.70"),27050); sc2.send(pkt); System.out.println("SENT"); //Receber DatagramPacket pkt2 = new DatagramPacket(new byte[1024],1024); sc2.receive(pkt2); String recived = new String(pkt2.getData(),0,pkt2.getLength()); aux = recived.split(" ")[2].trim(); sc2.close(); System.out.println("RECIVED - " + aux); . . .
The problem it's, this work's on Windows but it DON'T work on ubuntu(server/desktop edition, iam not saying in linux, because i haven't tried in another destro).
I already checked IPtables everything related with router but i can't solve this, the code run until 1st System.out then it block's waiting for the response, but the response on ubuntu never arrived :S
Can some one help please?Last edited by Fubarable; 04-30-2011 at 05:58 PM. Reason: code tags added
- 07-28-2011, 09:00 AM #2
Member
- Join Date
- Jul 2011
- Posts
- 1
- Rep Power
- 0
Hi. seem to be i have a same problem like yours.. but until now i still figure it out how to managed this.. does anyone have a solution for this.?
- 08-06-2011, 08:03 PM #3
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
Have you tried sleeping*?
Also have you tried loopback address (127.0.0.1) instead of your IP?
How is it going with TCP?
*That is insert short [c:a 100 ms at most] sleeps between statements.Last edited by Hibernate; 08-07-2011 at 06:38 AM.
Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
Similar Threads
-
JDBC Problem On linux
By arshadalisoomro in forum JDBCReplies: 2Last Post: 03-10-2011, 03:56 PM -
problem with browser Listener in linux
By chakribobby in forum SWT / JFaceReplies: 0Last Post: 06-14-2010, 03:54 PM -
Problem with FreeRapid in Linux
By jacatone in forum Java AppletsReplies: 5Last Post: 06-13-2010, 05:03 AM -
[SOLVED] Windows Linux conflict - TrayIcon image not display in Linux
By Eranga in forum Advanced JavaReplies: 6Last Post: 04-08-2009, 04:05 AM -
problem with ServerSocket on Linux
By gabriel in forum New To JavaReplies: 1Last Post: 08-07-2007, 04:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks