Slow new DatagramSocket()

I have an applet which creates a DatagramSocket. Creating the socket takes about 10-13 seconds. When running the same code on my machine within eclipse it is not this slow. Why does it take so long?
Full code:
public class ChessApplet extends JApplet {
     private UDPReceiver receiver;
     private DatagramSocket socket;
     private Thread thread;
     private UDPSendImpl sender;
     private ChatController chatController;
     private MoveLossHandler moveLossHandler;
     private ChessController chessController;
     @Override
     public void init() {
          initGUI(getParameter("serverIp"));
     @Override
     public void destroy() {
          socket.close();
     private void initGUI(final String serverIp) {
          if (SwingUtilities.isEventDispatchThread()) {
               doInit();
          } else {
               try {
                    SwingUtilities.invokeAndWait(new Runnable() {
                         public void run() {
                              doInit();
               } catch (Exception e) {
                    Util.log(e);
          new Thread(new Runnable() {
               public void run() {
                    try {
                         socket = new DatagramSocket();
                         sender = new UDPSendImpl(serverIp, socket);
                         chatController.setSender(sender);
                         moveLossHandler.setSender(sender);
                         receiver = new UDPReceiver(moveLossHandler, chessController, chatController, socket);
                         thread = new Thread(receiver);
                         thread.start();
                         sender.requestAllGames();
                         SwingUtilities.invokeLater(new Runnable() {
                              public void run() {
                                   moveLossHandler.setSender(sender);
                                   chatController.setSender(sender);
                                   chatController.setChatLoginButtonEnabled(true);
                    } catch (final Exception e) {
                         SwingUtilities.invokeLater(new Runnable() {
                              public void run() {
                                   JOptionPane.showMessageDialog(null, "Unable to start application: " + e.getMessage());
          }).start();
     private void doInit() {
          try {
               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (Exception e) {
               e.printStackTrace();
          try {
               JPanel top = new JPanel(new BorderLayout());
               top.setBorder(BorderFactory.createLineBorder(Color.BLACK));
               ChatView chatView = new ChatView();
               chatController = new ChatController(chatView);
               JMultipleChessView chessView = new JMultipleChessView();
               chessController = new ChessController(chessView);
               moveLossHandler = new MoveLossHandler(chessController);
               JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, chessView, chatView);
               split.setDividerSize(4);
               split.setBorder(BorderFactory.createEmptyBorder());
               split.setDividerLocation(0.7d);
               split.setResizeWeight(0.7d);
               top.add(new HeaderPanel(), BorderLayout.NORTH);
               top.add(split, BorderLayout.CENTER);
               setSize(new Dimension(800, 600));
               add(top);
          } catch (Exception e) {
               Util.log(e);
     public static JFrame startGUI(String host) throws Exception {
          JFrame frame = new JFrame("Test Frame");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(800, 600);
          frame.setLocationRelativeTo(null);
          ChessApplet comp = new ChessApplet();
          comp.initGUI(host);
          frame.getContentPane().add(comp);
          frame.setVisible(true);
          return frame;
     public static void main(String[] args) throws Exception {
          startGUI("tyken.net");
}

Tyken wrote:
I have an applet which creates a DatagramSocket. Creating the socket takes about 10-13 seconds. When running the same code on my machine within eclipse it is not this slow. Why does it take so long?
Full code:
     private UDPSendImpl sender; // Full code? Where is this class defined?
     private void initGUI(final String serverIp) {
          new Thread(new Runnable() {
               public void run() {
                    try {
                         socket = new DatagramSocket();
                         sender = new UDPSendImpl(serverIp, socket);
     public static void main(String[] args) throws Exception {
          startGUI("tyken.net");
Does "ping tyken.net" take the same time to resolve the hostname on these two systems?

Similar Messages

  • 10.5.2 = Slow new MacBook Pro

    Hello,
    I recently installed the 10.5.2 update, and the Leopard Graphics Update 1.0, and my new MacBook Pro is more sluggish than before. i just purchased teh system last week, and I can certainly notice a speed difference after these updates. Applications take longer to open, and the finder is not as responsive. Has anyone else had these problems? Can this update be removed? I'm so disappointed, as my new system now feels slow!!
    Thank you for your help!!!!
    Justin

    They had you do what I would have. You can also try resetting the Pram:
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    Try this and see if it helps any. The Pram is your memory.
    Ray

  • Very slow new T510i, need advice.

    Hi All, I have a new T510i, which I have been using for about a month.
    Its a i5 M 430 @ 2.27GHz with 2.00 GB of installed RAM
    I'm running Windows 7 Professional 32 Bit with Zone Alarm Anti virus.
    My previous laptop was a Dell Latitude which was 5 years old. The motherboard developed a fault, hence the new Thinkpad.
    I use the computer for Microsoft Outlook 2003 and for AutoCAD Architecture 2010.
    The computer is unbelievably slow and I do not know why.
    With just Outlook running, in the Task Manager it shows
    114 processes
    less than 15% CPU Usage
    70% + Physical Memory
    If I open AutoCAD then I'm up at 80-90% Physical Memory.
    When opening two AutoCAD drawings I have seen acad.exe running at 900,000 K Memory (Private Working Set)
    My old Dell ran Outlook 2003 and AutoCAD 2008 without too many problems.
    What should I do? Will sticking another 2 GB of RAM solve all my problems
    I have to live with this computer for 3+ years, so things are not looking good.
    Side issue, the in built microphones next to the screen packed up less than a week after receiving the Thinkpad.
    Thanks in advance.

    Hi Lead_org,
    Thanks for your help.
    Thinkpad has
    Graphics Processor / Vendor Intel HD Graphics Dynamic Video Memory Technology 5.0, which I think is onboard?
    The AutoCAD I generally do is 2D, not very complex. I'm a Structural Engineer!!
    Just is case this is relevant, when accessing the office network, the computer takes quite a few moments thinking what folders and files are available on the server.
    Changing the thinkpad to the W500 is not an option as the Lenovo reseller is unlikely to refund me the cost of this one
    Kind regards

  • Slow New Mac

    I just sprung for the new 2Ghz Duo Core MacBook and named it Flash because I expected it to be super fast. I had previously had a 1.3 Ghz single processor PowerBook that lasted me many good years but I thought was worth giving up to use Aperture and FinalCut fast with the x2 processors. Yeah for speed!
    Sadly, Flash is not living up to his name. In fact, my new MacBook is running so slow I'm thinking I screwed up by getting a new one. One possibility: I had a gig of RAM in my old laptop and have only 1/2 that in this puppy. But basic tasks and applications take SO much time to process (e.g. volume adjustment, opening applications) that I doubt its the RAM and am worried I have a bigger hardware problem. Scanned for spyware, viruses etc / came up 0% and never had any network issues before.
    My Q: is this a typical hardware of OS problem that people have been having with the new MacBooks?
    Thanks for the help!
    MacBook 2Ghz Processor   Mac OS X (10.4.8)  

    Hello,
    I went through the exact situation with my mac mini. The problem however is the ram. I have no idea why apple makes MacBooks or minis with 512 ram because that is completely insufficient for non UB Programs. Basically this is the breakdown of what happens:
    Why is my computer so slow when opening programs ?
    Your processor is super quick, your ram is actually quite quick, your hard drive is quick, your video card is o..k but not horrible. However, your 512 MBs of ram is completely insufficient so your computer slows down completely due to it. Think of it like a weak link in the chain, with one weak link your whole computer breaks down easier.
    Why is 512 so insufficient?
    Well what happens is your 512 MB of ram is actually more of 430 because 80 MBs gets used up by the integrated graphics card. Ok so 430 is still decent right? Wrong. When running anything not universal binary (MS Office, Most Adobe Programs and tons of other stuff) your computer need about 512 Ram to properly run/open those programs in a snappy fashion. However you don't have 512 MB of ram because your video card and Rosetta take at least half that. This doesn't work well. Because of Rosetta your computer demands a lot when running stuff thats not Universal, unless you have at least 1 Gig of ram. I'm sure when your opening Safari and iTunes and iPhoto you don't experience a slow speed. This is because 512 MB of ram is fine for most Universal Programs, but when Rosetta needs to rewrite PPC written stuff in a matter of seconds, you will quickly find a slow down. This is especially true when opening programs. While opening programs, Rosetta does most of it's rewriting to prevent major slowdowns while using the apps. Because of this, programs can take up to 15 Seconds + just to open. (Unbearable for a new computer)
    You've mentioned Rosetta A Lot and Universal Binary And PPC what is this? (Sorry if I'm being condescending just trying to help)
    PPC: PPC is the code used to write all programs in the G3-G5 series and previous old school processors. This code is made for macs specifically.
    Universal Binary (UB): Universal Binary is the code used to be recognized by Intel Processors. Most programs now a days are written in this code since apples switch to Intel. The programs are all eventually going to switch (Unless they're really old or uncommon).
    Rosetta: Rosetta is a background task which rewrite PCC codes into UB, all in a manner of microseconds. However, this process is usually mostly done when launching programs. It also takes up lots of ram. For games this isn't done completely at launch up becasue there is so much code to be written so you'll find most non UB games unplayable on the Macbook. This results in huge waits for programs to open which aren't UB unless you have sufficient ram which supports the process to go much quicker. Even with sufficient ram though, Non UB programs (Especially graphicly intensive programs like games and photoshop etc.), they will be slower in Rossetta then they should be (Maybe even slower then your old Computer). This however is temporary because, like i said upcomming relaseses and patches will be in UB.
    Suggestions:
    My suggestion is if you can, return your macbook and buy more ram (Not that huge of a price increase for something so essential). If you can't return it, spend the extra cash when you can and get more ram. If you do that, you'll find your computer running much much faster and you shouldn't experience a slowdown when running multiple applications as well. If you plan on using Photoshop and other programs simultaneously you may want to even consider 2GBs of ram (if your budget permits it) but thats not necessary unless your a major multitaskers. In fact, 2 GBs of ram would be a waste if you don't multi task a lot because it won't do much for gaming or video intensive tasks because then your weak link would be the Integrated Graphics not the ram.
    If however, you completely can't afford more ram, just be patient. Eventually everything will be written in Universal Binary. This will make your computer much faster as time goes on (Usually the opposite). Software hasn't caught up to hardware yet, so if you can't afford more ram, just wait for the speedup.
    I know it's kind of a complex subject and I'm not good at explaining. My laziness also results in a lack of proper English which I'm guessing also doesn't help. But i hope you have a understanding of why Flash isn't so Flashy.
    Good to luck to both you,

  • Very slow new broadband

    Hi
    I am a new customer to BT broadband and after setting up the HUB the first day or two it ran smooth. Now It is really slow and sometimes disconnects.
    I have done the speed test and the results are below
     Download Speed
     24 Kbps
    0 Kbps 250 Kbps
    Max Achievable Speed
     Download speed achieved during the test was - 24 Kbps
     For your connection, the acceptable range of speeds is 100-250 Kbps.
     Additional Information:
     Your DSL Connection Rate :284 Kbps(DOWN-STREAM), 780 Kbps(UP-STREAM)
     IP Profile for your line is - 135 Kbps
    2. Upstream Test:  -provides background information.
     Upload Speed
     209 Kbps
    0 Kbps 780 Kbps
    Max Achievable Speed
    >Upload speed  achieved during the test was - 209 Kbps
     Additional Information:
     Upstream Rate IP profile on your line is - 780 Kbps
    ADSL line status
    Connection Information
    Line state Connected
    Connection time 0 days, 00:41:29
    Downstream 287 Kbps
    Upstream 780 Kbps
    ADSL Settings
    VPI/VCI 0/38
    Type PPPoA
    Modulation G.992.5 Annex A
    Latency type Interleaved
    Noise margin (Down/Up) 15.9 dB / 9.6 dB
    Line attenuation (Down/Up) 51.8 dB / 28.0 dB
    Output power (Down/Up) 7.1 dBm / 1.8 dBm
    Loss of Framing (Local/Remote) 0 / 0
    Loss of Signal (Local/Remote) 0 / 0
    Loss of Power (Local/Remote) 0 / 0
    FEC Errors (Down/Up) 28 / 103547
    CRC Errors (Down/Up) 1 / 62080
    HEC Errors (Down/Up) 0 / 0
    Error Seconds (Local/Remote) 1 / 21763
    Thanks for any help or advice

    Hi David4674,
    Thanks for the post and welcome to the forum.
    After your broadband has been activated your line will go through a 10 day stabilisation period.  Your connection speed can be expected to fluctuate within this stabilisation period.  Have you noticed any improvement so far?
    Looking at your speed results it seems your IP profile has hit rock bottom at 135.  Do you sometimes notice that you temporarily lose connection?  It is very important that you leave your hub on as much as possible especially within the training period.
    Please drop us an update and let us know how your connection is performing now.
    Cheers
    Sean
    BTCare Community Manager
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • Very slow new Satellite L40

    I'd be grateful for any help you guys can give me.
    I have a new-ish Satellite L40 (bought last autumn). It's a dead basic machine -- Intel Celeron / 1.60GHz / 1015 RAM -- running Vista Home Premium. It was bought just to do word processing work + some very light internet use. The problem is that it runs very slowly (including taking forever to get going when I first turn it on).
    I've virus tested it to death. I regularly run spyware detection / elimination programmes. I've cut the number of start-up programmes right back. All the results say I've got a clam machine. But still it's as slow as hell. And when I say slow, I can just about make a cup of coffee in the time it takes to access the net.
    I've contacted Toshiba technical support, and the best they could suggest was that I reformat the hard disk, which is pretty drastic. If anyone out there has a better suggestion, I'd love to hear it. Right now, I'm rather regretting my initial purchase.
    Thanks a lot -- Max
    Message was edited by: ADMIN

    > I've contacted Toshiba technical support, and the best they could suggest was that I reformat the hard disk, which is pretty drastic. If anyone out there has a better suggestion, I'd love to hear it. Right now, I'm rather regretting my initial purchase.
    To be honest this drastic solution is not a bad proposal.
    But what do you mean exactly with slow machine???
    How long do you need for a booting?
    Fact is that many applications are preinstalled on this notebook and this could be a main reason for a long booting. But fact is that many of these applications are necessary to run all the notebook features.
    Furthermore a antivirus program which is running in the background and could affect the booting time. Long time ago I have used the Norton Antivirus and this software was a reason why my notebook was very slow... I changed it and now I'm use the freeware software like Antivir. It's much better...

  • [Solved - ext4 is just super slow] New Install Seems Very Slow

    After 8 years of Gentoo I decided to replace my main development box with Arch.  No X, just screen, emacs, w3m, and various compilers/languages.
    My old box is a 5 year old Gentoo box.  AthlonXP 2200 (1.7Ghz), 512M.
    The new Arch box is a based on a Shuttle K48.  It's got an Intel E2200 (Dual Core, 2.2Ghz), 2G, new SATA drive.
    Just to see I did a clean checkout of Clojure (a new JVM language) and did a "ant" on both boxes.
    Gentoo: 20 Seconds
    Arch: 51 Seconds
    I don't think it's a Java issue (same JVM version btw), it's just the only thing I can really think to compare it against.  When Arch hits the compile step I hear a fan go off and my hard drive light stays on for the durations.    I used ext4 on the drives, gentoo is using reiser.  Nothing else seems particularly slow, but I'm not doing anything on it really like I said.  A pacman install will happen almost instantaneously (which after 8 years of Gentoo is a welcome change).
    Anyone have any ideas?  I'll post whatever info you think might be useful.
    Thanks.
    Last edited by baetis (2009-05-02 16:02:40)

    So I reinstalled with reiserfs so the comparison would be against the same filesystem type.  The compile time on arch is now down to 20 seconds.  It still doesn't make sense though.  The compile is using 2 2.2Ghz cores, it should be crushing my old Gentoo box.
    I might try again with ext3.
    If anyone is curious if their ext4 shows similar issues try this (you'll need 15M on an ext2 /boot partition):
    On an ext4 partition:
    pacman -S svn
    pacman -S jdk
    pacman -S apache-ant
    svn checkout http://clojure.googlecode.com/svn/trunk/ clojure
    cd clojure
    ant [take note of time]
    As root:
    cd /boot
    cp -R <path to where you checked out clojure> .
    cd clojure
    ant clean
    ant [compare times]
    Do it a few times, ant clean then ant on both partitions and see how you fare.

  • Slow new phenom 9600 black

    Ok I am going to start from the beginning. i upgraded my old computer with parts off newegg
    New motherboard: MSI K9N2 SLI Platinum AM2
    New cpu: AMD phenom x4 9600 black
    New ram: CORSAIR 4GB (2 x 2GB) 240-Pin DDR2 SDRAM DDR2 800
    New Video Card: Evga geforce gtx 260 216 superclocked
    New Power supply: 650w with two 12v rails at 25 amps
    Got the parts put it all together all green leds all is looking flawless. Went to install windows vista ultimate noticed that it was hanging up longer then normal
    between screens noticeably longer (have done alot of window installs) shrugged it off and continued the install got into windows installed all the drivers with
    the disks. still kinda wondering about the sluggishness, I ran a test in 3dmark vantage worst fear came true 5000 very very low score for the system
    restarted the computer got 4 red leds indicating the it had a defective or incorrectly installed cpu but still boots up into windows just fine. got a cpu monitor
    shows activity from all 4 cpu's.  went online to get all the new drivers from the websites for the gtx 260 and motherboard, Same thing. removed cpu to look at
    the pins looked good installed my old copy of windows xp same thing. It would hang up longer then normal on the install did just as bad in 3dmark06
    removed 1 stick of ram guess what all leds went green thought I might have found the problem. same thing bad 3dmark vantage score replaced the ram stick
    that I took out, boot's up with all green leds now every time but still slow system. I am at a loss is there anyone that can help me out there. Maybe recommend
    any testing programs that can narrow it down. I am suspecting the cpu or motherboard. this is driving me crazy
     

    Quote
    i cant find the 3.2 bios update
    the one that shows up for my mobo are the 2.1
    k9n2 diamond
    ??? Are you contradicting yourself? In your first post, you list in your system specs:
    Quote
    New motherboard: MSI K9N2 SLI Platinum AM2
    Better make sure you know exactly which mainboard you have before progressing further...
    And before you even think about flashing your BIOS, you must get that system stable! And what are your exact PSU specs too please!
    K9N2 SLI Platinum BIOS:
    http://global.msi.com.tw/index.php?func=downloaddetail&type=bios&maincat_no=1&prod_no=1443
    >>Use the MSI HQ Forum USB flasher<< 

  • Slow New MacBook Pro and Migration

    Are there pros and cons to using the Setup Assistant to migrate files and applications from an older computer?
    I migrated my system from a PowerBook G4 to my brand-new MBPro.
    I've noticed that recently I'm getting some very s-l-o-w performance.
    Could this be because I migrated?
    Is it a better idea to start fresh and transfer items myself?
    So. This is a question, but more of a "is it better to ...?"

    The benefit of using the Migration Assistant is the obvious one, fast transition and setup time.
    However, when it comes to a PowerPC to Intel transition it doesn't always go as smoothly as one would like. One of the downsides is possible poor performance which you have. The problem here is that at times important libraries are actually downgraded from Intel version to PowerPC version which absolutely kills performance.
    Most likely your problems are due to the use of the MA and it is normally suggested that a manual transition be done of it fails such as your case.

  • Very Slow New Mac Pro

    I just got my first Mac Pro. I upgraded to Yosemite. It took nearly 5 hours to download. I thought it would have been and internet problem. But then I noticed that almost everything is slow, I am cutting the cord with PC but I expect a difference!
    Opening an app takes several seconds. I have seen my friends Macs and they have almost instant opening of apps and all. It seems awfully slow to me.
    Also I noticed that RAM is constantly on 3.98 or so, and many times there is only a few MB available. Who is using all the mem?
    Thanks for any advice.
    JC

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.
    If you bought the product in the U.S. directly from Apple (not from a reseller), you have 14 days from the date of delivery in which to exchange or return it for a refund. In other countries, the return policy may be different. If you bought from a reseller, its return policy applies.

  • Help netbook slow new

    Ok my  samsung n130 netbook is very slow .I went back to best buy and bought bigger memory 2gigs still slow .Please tell me what else to do.....thanks
    Solved!
    Go to Solution.

    Jaxjags2100 wrote:
    Don't upgrade to 7 you're better with XP. Two items I'd suggest downloading.
    1. CCleaner found at www.ccleaner.com
               - Run it to clean your system of junk and also run the registry cleaner as well
    2. Auslogics Disk Defragmenter found at www.auslogics.com or www.download.com
              - In my experience it's the quickest and most efficient disk defragger I've come across.
    The netbook already comes with Win7 Starter.
    *******DISCLAIMER********
    I am not an employee of BBY in any shape or form. All information presented in my replies or postings is my own opinion. It is up to you , the end user to determine the ultimate validity of any information presented on these forums.

  • How to handle multiple clients with DatagramSocket

    I am trying to handle multiple clients with 1 datagramSocket bind to one port (basically I have only one port to use, and I can not use TCP or any other ports). At the server side I have two threads one for receiving packets and buffering them, another for processing the packets in the buffer and sending replies.
    I can have multiple clients sending datagramPackets to me and I will have to process the packets and send them to DIFFERENT clients. Ex. Client 1 sends datagramPacket to Server which sends the processed packet to Client 2. Also Client 2 sends a datagramPacket to Server which again processes the packet and sends it to Client1. May have Client 3 and 4 doing the same thing at the same time... and so on...
    My root class is creating the datagramSocket(somePort) and two threads (receiver and sender). How can I use the socket that I created in these two threads??
    I have done the following and I am getting "java.net.bindexception". When I am sending stuff from Client1 to Client2 everything is fine but when I start sending something from Client2 to Client 1, I get the bindexception... Client 1 is using port 3000, Client 2 is using port 4000.
    I really don't have a lot of experience in socket programming so I am not sure if there is a much simpler way to do this. I appreciate all the tips and help that I can get...
    Thanks...
    class UDP_serv
         static DatagramSocket udpSocket;
         final static int SERVER_PORT     = 2000;
         public static void main(String[] args) throws SocketException
              udpSocket= new DatagramSocket(SERVER_PORT);
              new DataReceiver().start ();
              new DataSender().start ();
         static class DataReceiver extends Thread
              DataReceiver()
                   Thread.currentThread().setName("DataReceiver");
              public void run()
                   while (true)
                        byte pckt[] = new byte [MaxMsgSize];          
                        DatagramPacket dp = new DatagramPacket (pckt, pckt.length);
                        try
                             udpSocket.receive (dp);
                             //PUSH TO RECEIVE BUFFER
                        catch(Exception e)
                             e.printStackTrace();
         static class DataSender extends Thread
              DataSender()
                   Thread.currentThread().setName("DataSender");
              public void run()
                   while (true)
                        processDataMsg();
          static void processDataMsg() 
             DatagramPacket op;
             InetAddress DA = null;
             int DP = 0;
             byte [] outPacket = null;
             // POP FROM RECEIVE BUFFER
             // SOME PROCESSING HERE     
             // Set Destination Address (DA)
             // Set Destination Port (DP)
             // DA and DP are the forwarding IP and Port addresses
             // not the addresses original packet was sent from.
             try
              op = new DatagramPacket (outPacket, outPacket.length,DA, DP);
              udpSocket.send(op);
             catch (IOException e)
              e.printStackTrace();
    }Also for development and testing purposes, I am running the two clients and the server on the same machine (windows xp-32b) so all of the Destination IP Addresses are 127.0.0.1. and as I said Ports that I am using are 2000, 3000, 4000 (Server, Client1, Client2).

    Hmm I have minimized the code and it seems to be working now.
    I think I have an error in the header portion of the data I am sending, where I am storing the source IP/Port and destination IP/Port. I think the server in the middle is messing these values up while sending them to the destination Client. Because the destination client actually receives the stuff and sends the reply back to the server, but the reply packet's headers has 0/0 as the dest IP / Port...
    Server is giving me java.net.BindException: Cannot assign requested address error when it tries to forward the reply it received from the client2 as the address it is trying to send is 0!
    I guess it doesnt just give this error when you try to open two sockets to the same port...
    Paul, Thanks for the direction on how to proceed... took me a while get the minimized code but at least figured out the problem. Well still have to make sure that is THE problem though :)
    As far as the statics goes how can I change those to non static ones? Where do I make an instance of the top level class that creates the threads? and how do I pass the DatagramSocket to the threads/ if I dont need to pass how do I call or use the datagramSocket I created in the top level class? I mean do I still kinda have it like a global variable on the top?? A very simple example would be much appreciated...
    I think these might be really basic questions but I am having a rough time with the hierarchy in java...

  • DatagramSocket not picking up UDP broadcasts

    Hi All.
    Opened a DatagramSocket on specific port. Verfied (w/ tcpdump) that other process is sending UDP packets to that port with broadcast address (128.0.3.255). {pseudocode}DatagramSocket.recieve(dgram) never picks up the packets.
    If I change the sender to use specific IP (unicast), the recieve gets the packet and unblocks.
    JRE1_5
    Any ideas?
    -K

    Are you binding the socket to the wildcard address?
    Is that really your broadcast address? The 128.0.0.0/16 address block is slightly unusual (RFC 3330). broadcast = ip_address | ~netmask; (or use 255.255.255.255).
    Try these programs; do they work for you? If they do, what is different between these and your program:
    import java.io.*;
    import java.net.*;
    public class BroadcastSend
        public static void main(String args[])
         throws Exception
         DatagramSocket socket = new DatagramSocket();
         socket.setBroadcast(true);
         socket.setReceiveBufferSize(64 * 1024);
         socket.setSendBufferSize(64 * 1024);
         int str_size = args.length == 0 ? 256 : Integer.parseInt(args[0]);
         StringBuffer str = new StringBuffer();
         while (str.length() < str_size)
             str.append("hello world");
         str.setLength(str_size);
         byte buf[] = str.toString().getBytes("ISO-8859-1");
         InetAddress address = InetAddress.getByName("255.255.255.255");
         DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 6666);
         socket.send(packet);
    import java.io.*;
    import java.net.*;
    public class BroadcastReceive
        public static void main(String args[])
         throws Exception
         DatagramSocket socket = new DatagramSocket(6666);
         socket.setBroadcast(true);
         socket.setReceiveBufferSize(64 * 1024);
         socket.setSendBufferSize(64 * 1024);
         while (true) {
             byte buf[] = new byte[64 * 1024];
             DatagramPacket packet = new DatagramPacket(buf, buf.length);
             socket.receive(packet);
             System.out.println("got " + packet.getLength() +
                          " bytes from " + packet.getAddress());
    }

  • DatagramSocket problem when using IPV6

    Hello,
    I've got an odd problem. I have to adapt a program to work with IPV6. The code below exemplifies my problem:
    public static void main(String[] args) {
         try {
            String serverHostname = new String ("fd22::1");
            Inet6Address inetd6 = (Inet6Address)InetAddress.getByName(serverHostname);
            Inet6Address inet6 = (Inet6Address)InetAddress.getByName(new String("fd22::3"));
            DatagramSocket clientSocket = new DatagramSocket(5080, inet6);
            byte[] msg = new byte[1025];
            DatagramPacket dp = new DatagramPacket(msg,msg.length,inetd6,7000);
            clientSocket.send(dp);
            clientSocket.close();
        } catch ( IOException ex ) {
        ex.printStackTrace();
    }When I send messages with more than 1024 bytes to a machine that does not exist in my network ( fd22::1 is not valid ). I get the following output:
    java.net.SocketException: Interrupted function call: Datagram send failed
            at java.net.PlainDatagramSocketImpl.send(Native Method)
            at java.net.DatagramSocket.send(Unknown Source)
            at Main.main(Main.java:23)I don't think this code is supposed to throw a SocketException. When I send a datagram to an invalid IPV4 address, it's not a problem. UDP is connectionless, so I can't figure out the problem here.
    ps.:Working in Windows XP

    The Java Version I'm using is 1.6.0_26 . I'm binding the DatagramSocket because, at the original program, the user may choose which IP address he wants to use as source. I've got over 200 IP addresses in my PC.
    I tried the code without the binding, but the problem persists.
    What did work was running this code on another machine (different network). I ran it on Linux, I was also using Java 6, from Oracle. I just don't remember which update was.
    Could it be a problem with the JVM or the network? IPV6 works just fine if I'm trying to send datagrams to valid addresses or really small datagrams to invalid adressess.
    I don't know whether it is relevant or not, but the IP addresses on my network were manually configured.

  • DatagramSocket

    Hi I'm trying to build a simple test app using DatagramSocket (AIR 2) and I'm wondering if I absolutely need to use a server in order to communication with other applications on the local network. I have a simple test where I have 2 air apps on my home network, app "A" and app "B" (wireless connected laptop and desktop). I have an animation in app A and app B that are identical. I want the animation in app A to sync with app B, so I want app A to tell app B what frame it's currently on, and app B should update it's frame number accordingly. I'm am pretty new to using DatagramSocket, and I'm not even sure that it's the best thing to use. I just figure UDP would be a lot faster than using TCP in the case where there are a lot of things moving on the screen.
    If anybody can point to examples of sending UDP over a local network that would be great, or post some code, give insights etc.
    Thanks.

    I don't understand what the problem is now.The problem is that 1st time when Timeout occurs it throws exception. In catch block i caught the exception and call some function to perform some task. up to here every thing is fine but problem comes when loop iterates for 2nd time* the socket hangs and doesn't throw any exception when Timeout occurs. I m not sure whether Timeout occurs or not. Here is some piece of code.
    Some Code Here......
    try {
          mnSocket = new DatagramSocket(PORT);
          mnSocket.setSoTimeout(10 * 1000);
          mnSocket.setSendBufferSize(bufferSize);
          mnSocket.setReceiveBufferSize(bufferSize);
          mnSocket.setSoTimeout(10 * 1000);
          sendSolic = new SenderThread(mnSocket, 2);
          solicPacket = new DatagramPacket(buffer, buffer.length);
          while (true) {
            try {
              mnSocket.receive(solicPacket);
              Some Code Here...........
            catch (SocketTimeoutException ste) {
              sendSolic.start();
            Some Code Here........
        catch (SocketException se) {
          se.printStackTrace();
        catch (IOException ioe) {
          ioe.printStackTrace();
       Some Code Here........

Maybe you are looking for

  • Windows XP 64 Bit Service Pack 3?

    Hey All: I have a Lenovo B570 with 8GB of DDR3 memory and an i3 Processor, and I want to put XP on it after I install my new screen, and I was going to slipstream service pack 3 into an iso and use that, but I cannot seem to find an SP3 64-bit exe fi

  • Dick Permission--"ACL" found but not expected...

    Safari/internet access is great after I do a disk permission verify & repair. After a week or so it is back to the slow mode. WHAT is "ACL"? and why does it go back after I have repaired the disk permissions? Here is a typical line of the detail ACL

  • Unable to find jvm.dll problem

    Hi, The problem is how to let windows know the jvm.dll is located at c:\jdk1.3\jre\bin\classic. When I execute invoke.exe, it will say unable to create JVM, bcoz jvm.dll not found. If I copy the invoke.exe in c:\jdk1.3\jre\bin\classic, it is working

  • Sharepoint 2010 - Pop Up error message

    Just wondering if anyone can help me.... We are running sharepoint 2010 on server 2012. We have a site page which contains embedded google maps, and when we set it to display as a modal pop up box as opposed to the full page we receive an error messa

  • HT4623 after trying to update ios my phone will not do anything, just shows charder with arrow pointing to my iphone symbol, wht?

    i was trying to update ios and after i was complete i can not do anything with my phone now it just shows the charger with an arrow pointing to the itunes symbol, i cant get out of that, what can i do?