UDPDatagramConnection.receive did not return a package

Hello!

I wrote a simple program that send and receive packets UDP (parts of the DNS resolver).

I use BlackBerry Bold, 9000 v4.6.0.266 (Platform 4.0.0.233).

Connection Wi - Fi, sniifer AirPcap I see my program to send and receive datagrams.

The problem as the return of the thread that read waiting datagram in UDPDatagramConnection.receive () and does not.

I send and receive UDP from the same UDPDatagramConnection 2-wire separated package.

I try both commands open when the connection:

"udp: / /; interface wifi =' and

"udp: / /" + dnsServer + ": 53; 5070 "+"; " = wifi interface.

But it did not work.

Thank you.

Igor.

package com.mailvision.dns;import java.io.IOException;

import java.util.Timer;import java.util.TimerTask;import javax.microedition.io.Connector;import javax.microedition.io.Datagram;import javax.microedition.io.UDPDatagramConnection;import net.rim.device.api.io.DatagramConnectionBase;import com.mailvision.mvutil.Log;

public class UDPClient {   static final String TAG = "DNS"; static final int DATAGRAM_MAX_SIZE = 2048;   static final Timer timer = new Timer();  String dnsServer;    String netInterface; int responseTimeoutMs;   int repeatNumber = 2;    int repeatDelay = 1000;  UDPDatagramConnection conn;  TimeoutTimerTask timeoutTimerTask;   Receiver receiverThread; Sender   senderThread;   byte [] query;   byte [] result;

 static class Receiver extends Thread {       UDPClient uc;        public Receiver(UDPClient udpClient) {         uc = udpClient;        }                       public void run() {           try {                byte [] buffer = new byte[DATAGRAM_MAX_SIZE];                Log.d(TAG, "receiver started");              Datagram dgrm = uc.conn.newDatagram(buffer, buffer.length);              Log.d(TAG, "receiver wait dgrm");                uc.conn.receive(dgrm);               Log.d(TAG, "receiver receive dgrm");             uc.result = dgrm.getData();          } catch (Throwable e) {              Log.e(TAG, "receiver", e);           }        }    }       

        static class Sender extends Thread {     UDPClient uc;        public Sender(UDPClient udpClient) {       uc = udpClient;        }                       public void run() {           try {              Datagram sendDgram = uc.conn.newDatagram(uc.query, uc.query.length);             String sendTo = "//" + uc.dnsServer + ":53";             sendDgram.setAddress(sendTo);            for(int i=0 ; i < uc.repeatNumber && uc.conn != null ; i++){                Log.d(TAG, "before send to " + sendTo);              uc.conn.send(sendDgram);             Log.d(TAG, "after send");                Thread.yield();              try {                  Thread.sleep(uc.repeatDelay);              }  catch(InterruptedException e){}             }                               } catch (IOException e) {               Log.e(TAG, "send", e);             }           }      }    

           static class TimeoutTimerTask extends TimerTask {     UDPClient uc;                       public TimeoutTimerTask(UDPClient udpClient) {          this.uc = udpClient;       }                       public void run() {                          Log.d(TAG, "timeout timer - close connection");         uc.timeoutTimerTask = null;                           uc.close();       }       }    

           public UDPClient(String dnsServer, String netInterface, int responseTimeoutMs) {      this.dnsServer = dnsServer;      this.netInterface = netInterface;        this.responseTimeoutMs = responseTimeoutMs;      Log.d(TAG, "UDPClient constructor: dnsServer=" + dnsServer + " netInterface=" + (netInterface != null ?                         netInterface : "") +          " timeoutMs=" + responseTimeoutMs);     }        void close() {        try {            if (conn != null) {              conn.close();                Log.d(TAG, "connection is closed");          }        } catch (IOException e) {        } finally {          conn = null;     }      }     

          void createConnection() throws IOException {       //String cmd = "udp://";         String cmd = "udp://" + dnsServer + ":53;5070";        if (netInterface != null)        cmd = cmd + ";interface=" + netInterface;      conn = (DatagramConnectionBase) Connector.open(cmd);         Log.d(TAG, "connection open cmd=" + cmd + " localAddress=" + conn.getLocalAddress()            + ":" + conn.getLocalPort());    }     

          public byte[] sendrecv(byte[] query) throws IOException {            this.query = query;            createConnection();      receiverThread = new Receiver(this);            receiverThread.start();            Thread.yield();             senderThread = new Sender(this);             senderThread.start();            Thread.yield();            timeoutTimerTask = new TimeoutTimerTask(this);             timer.schedule(timeoutTimerTask, responseTimeoutMs);                Log.d(TAG, "sendrecv wait receiverThread");             try {  receiverThread.join();  } catch(InterruptedException e){}             Log.d(TAG, "sendrecev after join receiverThread");     if( timeoutTimerTask != null )                      timeoutTimerTask.cancel();                  close();       if( senderThread.isAlive() ){               try {                           senderThread.interrupt();               } catch(Throwable e){}                   }                       if( result == null ){                  Log.d(TAG, "sendrecv - response timeout");            throw new IOException("response timeout");                   }                   Log.d(TAG, "sendrecv - return response");                   return result;           }}

Problem is this expectation of the main thread of the test result use thread.join)

And RIM udp connection receive() use main thread to do internal work of connection.receive.

Therefore their link GUI and power outlets if "hang you" it somethere in the GUI, your UDP (= taken) connections stop working!

Tags: BlackBerry Developers

Similar Questions

  • Message that I do not have a real Windows 7 and Microsoft did not return my call is that I

    I expected a call from Microsoft for today at 11:30 to help with the problem posed by microsoft after uninstalling windows 10 & returning on Windows 7. My phone is this problem says I do not have a genuine windows 7 build 7601 what happens? How do you contact & help?

    Original title: Microsoft did not return my call scheduled this am

    ... [Windows is not genuine] problem [began after] uninstall windows 10 & returning to Windows 7.

    When and how you ' uninstall Win10 & back to Win7?

    Have you ever run the Norton removal or the McAfee Consumer products removal tool?

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    You can get sponsored by Microsoft (but not necessarily free) support through the Office of response-online http://answerdesk.microsoftstore.com

    ====================================================
    WARNING: Displayed AS IS without any warranty. MS MVPs represent or work for Microsoft.

  • McAfee said I've got a Trojon did not buy their package

    How to get rid of Trojans?

    http://www.Malwarebytes.org/products/malwarebytes_free/

    If you have McAfee, but did not purchase this program uninstall.

    Or perhaps you have installed a program that you have downloaded, and you did not read the installation windows uncheck option McAfee scanning program.

    When you install a program, usually a download internet you must read carefully the installation windows and ther options

  • Checking the status did not return ACS version after update 4.0 to 6.0

    We are in the (stable) the ACS of 4.0 to 6.0 upgrade process.  The only problem that we see, is that after the upgrade, check the State does not return a version.

    We use the check.js provided by Adobe, but get to the result of the call.

    .. / Status? check = version

    The appeal has changed, or are we missing a configuration somewhere property?

    I guess nobody don't Adobe never look at this forum...

  • Bridge did not return to Photoshop using BridgeTalk onResult

    I have a script that I am running in Photoshop that goes to bridge to get an array of information using the Exif metadata that are quickly accessible via thumbnails of bridge (it is really slow in Photoshop because you open the documents to get it).  My problem is that BridgeTalk seems to work very well by crossing the bridge script and I want to return an array of real numbers accordingly, but bridge never transmits the result.  Can I use $.writeln commands in the script focused on the bridge and see the bridge made the calculations, but it won't return anything that is accessible in the photoshop script.

    What I am doing wrong?

    FYI, I tried editing and execution of SnpSendArray.jsx (included in the SDK of bridge) to go back from Photoshop to the bridge, and it does not, either.  I wonder if I am doing something that is not possible.

    I got an answer to this problem in the other thread I posted.

    https://forums.Adobe.com/thread/1790424

  • Capacity Planner error: Registry did not return a valid connection.

    I don't know what I'm missing here, but I cannot collect my data of inventory for all my systems.  I use a domain administrator account and I have enabled all ports 135-139 and 445 on the Windows FW.  Remote registry is running (I've read that in a thread).  However, I keep getting this error.  Any ideas?

    Did you try what I suggested before - using the account you have provided for the collector of data for data collection, connect you to a windows PC or server and see if you can connect to remote registry or perform counters one of the servers at the origin of the problem.

  • My phone has been repaired for nearly two months and did not return.


    Update: got a phone call today and get a code to get a new phone for free. Finally going to pick up my phone.

  • Why are my returned email (Outlook Express) by Mail Delivery Subsystem saying does not return.

    Emails returned by Mail Delivery Subsystem, telling me that they are delayed, and did not return.  Have never seen this before.

    The same thing happens if you send a message to yourself? What is the exact message of delivery?

  • SG300-10 - DHCP server did not update DNS (bind9) records

    Hello community,

    My SG300 is configured in Mode L3 in my Homelab, and the DHCP server is enabled.

    The switch runs on the Version of the Firmware 1.4.1.3.

    I have configured by a Pool of network VLAN.

    The default router IP address (Option 3), the IP of the DNS (Option 6) and the domain name (Option15) are also configured.

    DHCP works fine without problems.

    Customers get their inclusive information of router, DNS, and domain IP Configuration name.

    As a DNS server, I configured a server bind9 under winded raspbian.

    The bind9 is configured to allow dynamic updates and DNS works as expected.

    Manually using NSUPDATE I can make dynamic updates to bind9 DHCP clients areas.

    But this isn't what I want.

    I want to make the SG300 DHCP server dynamic updates to the DNS zones.

    Would be the Option DHCP 81 (Client FQDN) useful?

    Any idea is welcome. :-)

    Looking forward to hear from you because it drives me crazy.

    Best regards

    Rainer.

    Sorry for the delay in reply Rainer.  I tried to set this up in my lab and became GUI of entry of unexpected results that did not affect the packages at all.  Checked with my contacts and they advised me that it is not supported on this switch option 81.  Given that the client sends to the server on how to update DNS records, the switch does not support this dynamic configuration.

    Referring to the data sheet for the SG300, these are supported options listed:

    DHCP (12, 66, 67, 82, 129 and 150 Options)

    Here is the link to the datasheet.

    http://www.Cisco.com/c/en/us/products/collateral/switches/small-business-smart-switches/data_sheet_c78-610061.html

    Sorry about the information, but is not a supported option.

    James

  • Did not receive the security updates June 2016 for Win7 Pro.

    Two of my three PC Win7 Pro received June downloads security on 15 June.  My third pc from today (July 1) did not get these downloads. The last time it was in May.

    I told Win. updated LOOK for downloads but it sets just there saying looking for UPDATES.  I waited an hour long, but nothing happens after that research, keep just on & on.

    Please note... I have no problem to download other applications.

    I wrote the numbers of June security update KB of my other PC.  Where can I download them manually?

    Try the following: manually install the client June 2016 update rollup package, including a new version of windows. Earlier versions may not manage patch day KB3161664 June. This would be a solution for now to install it manually, but with a high probability of the issue of his return on the day July patch.

    https://support.Microsoft.com/en-us/KB/3161608

    Before you install the updates manually, the value of the automatic updates to 'never check updates' and restart to avoid any research activity to interfere in the background.

    Best regards, VZ

  • I received undeliverable emails 15 to 03:19 and did not send emails to the addresses listed.

    I need to speak with someone from undeliverable emails that I did not create. I can be reached at +++ * +++ * +++

    Change the telephone number of the public to prevent the search bots to find.

    There is no phone support and display of your phone number is not a good idea. If you are too careless with your e-mail it is not surprising that a spammer has copied and it uses the return address of the Junk they send.
    There is nothing you can do to stop them now. They'll get bored with you soon and move to a new address borrowed. They probably don't use your real account, just the address. If they have been sent from your account messages would be in your "sent" folder.
    Be more protective of your personal information and stop posting in a public forum.

  • I can't change the questions to reset password also helps. In almost did not receive a letter with instructions

    I can't change the questions to reset password also helps. In almost did not receive a letter with instructions

    For a long time I don't remember creating answers to the questions that they tried to lose on the email I wrote not just the 2nd day.

    help solve the problem. I live in Ukraine. And there is no way to contact support.

    Hello! It is quite difficult to understand you.

    To reset the security questions, follow these steps:

    If you forgot the answers to your questions of security of Apple ID - Apple Support

    To have access to your forgotten Apple ID, follow these steps:

    If you have forgotten your Apple - Apple Support ID

    If you forgot your Apple ID - Apple Support password

    https://iforgot.Apple.com/appleid

    Also, take a look at this:

    On your Apple ID email addresses - Apple Support

  • I removed the nano-receiver to the USB port & back the mouse did not.

    I have 2.4 GHz Wireless Nano Mouse (model MP2375BLK) optics.  I removed the nano-receiver to the USB port & back the mouse did not.  Batteries are fine, if I remove the battery and put it back in the red light flashes once, but the mouse will not turn on.  I checked the State of the mouse in Control Panel control (devices & printers) and it indicates that the device is functioning!

    I thank God for warranties.  Just bought itOn June 3.  Summer works fine until I removed the nano-receiver of the laptop, did not work again!  Let's get back to the store.

  • I am running Windows 7 and noticed that Windows updates did not work. The parameters are defined for the update every day. When I went to update manually returned an error WindowsUpdate_80070017. MSFT site was no help. Any recommendations?

    I am running Windows 7 and noticed that Windows updates did not work. The parameters are defined for the update every day. When I went to update manually returned an error WindowsUpdate_80070017.  MSFT site was no help. Any recommendations?

    Since neither updates Jan - 10 have installed, I'm going to hand you Support MS in the hope that they can resolve the problem. See below.

    That being said, is an interpretation of the 80070017 - cyclic redundancy check error "a device attached to the system does not work," which suggests that a hardware problem might be the cause of the error (although I must say that it is a very low possibility in this case).

    Good luck!

    =======================

    Visit the Microsoft Solution Center and antivirus security for resources and tools to keep your PC safe and healthy. If you have problems with the installation of the update itself, visit the Microsoft Update Support for resources and tools to keep your PC updated with the latest updates.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • iTunes update errors with the following message appears: there is a problem with this Windows Installer package. A program run as part of the set up did not complete as expected.

    iTunes error update

    I am trying to install an update to iTunes on my laptop and find the folowing part-way through the installation error:

    "There is a problem with this Windows Installer package. A program run as part of the set up did not complete as expected. Contact your provider to support personal or package. »

    I got iTunes for 3-4 years now and have always been able to install updates successfully, so don't not sure what is the problem.

    I tried msconfig and changed the boot process, so it includes all of the non-Windows elements, as suggested on the Microsoft Web site, but that has not worked.

    Can anyone help?

    Thank you

    The instructions were to contact the vendor of the package. This isn't iTunes, Microsoft.

    Ask the question in the Apple Forums:
    https://discussions.Apple.com/index.jspa

Maybe you are looking for