UDP send receive application

Hi all

I'm writing an application to send UDP packets. I had no problem with the send() call, but I would try to receive the message sent, perhaps on the same connection.  (I use another connection to receive in the same thread, but the result is the same).

The application thus written, block in the first reception. Could someone help me?

package ProvaInvioRicezione;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.MainScreen;
import javax.microedition.io.Connector;
import javax.microedition.io.DatagramConnection;
import javax.microedition.io.Datagram;
import java.lang.String;

public class EsempioInvio extends UiApplication
{
public static void main(String[] args)
{
        EsempioInvio theApp = new EsempioInvio();
theApp.enterEventDispatcher();
}
public EsempioInvio()
{
pushScreen(new HelloWorldScreen());
}
}
final class HelloWorldScreen extends MainScreen
{
public HelloWorldScreen()
{
        super();
        LabelField title = new LabelField("Esempio di invio pacchetti",
                        LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Cambia stringa cazzo!"));
        //add(new RichTextField("Datagram packet was sent"));
        byte[] outBuff = "Soccia!".getBytes();
        byte[] buf = new byte[256];
    //byte[] buf = new byte[256];
    try {
        //creo socket per mandare il pkt

      DatagramConnection connection = (DatagramConnection)Connector.open("datagram://127.0.0.1:2000");
      Datagram outDatagram = connection.newDatagram(outBuff, outBuff.length);

      connection.send(outDatagram);

      DatagramConnection recConnection = (DatagramConnection)Connector.open("datagram://127.0.0.1:2000");
      Datagram inDatagram = recConnection.newDatagram(buf, buf.length);

      while(true){
          System.out.println("Ciao sono qua");
      recConnection.receive(inDatagram);

      String received = new String(inDatagram.getData());
      add(new RichTextField("Stringa ricevuta:"+received));
    }

    } catch (Exception e) {
        add(new RichTextField(e.getMessage()+":"));
        add(new RichTextField(e.getClass().getName()));
    }

}
public boolean onClose()
{
Dialog.alert("Bye bye n00b!");
System.exit(0);
return true;
}
}

Problem solved. I used another connection is listening on port even reeive data and udpdemo now work correctly. There was a funny bug tooc the sample application print a message from output og OK don't receive that if the payload of the packet is "RECEIVED"... the payload, not the status

Tags: BlackBerry Developers

Similar Questions

  • Thunderbird is no longer able to connect to internet (sending/receiving e-mail, update, creating a new account... Firefox connects fine

    24.4.0 version worked fine until yesterday (2014-04-06) running windows 8.1 and all of a sudden he couldn't connetc to the internet (sending/receiving e-mail, update, create a new account...). No change was made on my set up accounts. Other applications to connect correctly to the internet. Some Windows 8.1 updates are automatically applied during the same period (?).
    Any suggestion would be appreciated
    Rgds

    Hi the problem is resolved. I saw a small logo on the first login of Windows 8 window saying "no internet connection available. I connect to the internet before opening a Windows session, and after the opening of the session windows my Thunderbird work again as well as the update of ccleaner...
    It seems that, for this Windows 8.1, there are 2 types of internet connections... Mystery?

  • How to send / receive files via Wifi Direct... ?

    I found this bike e wifi Direct support. I tried to send files via wifi direct, but I couldn't.

    How to send / receive files with direct wifi without installing any 3rd party application... ?

    Uses of direct wifi... ?

    Sorry about that. Can be a regional thing, I'm not familiar with.

    Back to my question - what types of files you try to move?

  • Send/receive VI in LabVIEW to run on SMU...

    Is it possible to write a VI for send/receiver UDP messages that will run on the SMU RT computer?

    Nevermind, I got it. No not specified delivery address.

  • My emails are quadruplicating themselves. When I remove them, they disappear, but when I press send/receive back

    I use Outlook express for e-mail. Someone had a problem with the duplication of emails or their refusal to stay deleted?

    The other post:

    My emails are quadruplicating themselves. When I remove them, they disappear, but return when I press send/receive. I tried to mark them as read, and then delete them, but have had no success. What is the answer, please?

    Poster PA bear MS MVP on another post:

    Assuming that Outlook Express (which has nothing to do with Internet Explorer):

    1. move all the messages that you want to keep out of sent items anddeleted items folders and in other local OE folders have created you for archiving (backup) of such messages.

    1B. move 99% of your messages in your Inbox folder to other folders the of OE, too.

    2. Note the location of the store of your identity (http://www.insideoe.com/files/store.htm#storemain).

    2B. turn on "Show hidden folders and files" via start | Control Panel | Folder options | View (cf.http://www.bleepingcomputer.com/tutorials/tutorial62.html).

    3.-online close Outlook Express! <>

    4. in Windows Explorer [Windows key + E], access your storage folder, find & removeOutbox.dbx, Sent Items.dbxand Deleted Items.dbxfile.

    To avoid such problems in the future, comply with the following restrictions:

    N ' not use Inbox or sent items to archive messages. Move them to local folders created for this purpose.

    -Empty the deleted items folder daily.

    -Frequently perform a manual compact of all OE while records that "work offline". More onhttp://www.insideoe.com/files/maintain.htm

    -Do not cancel automatic compacting, where it would happen and do not try to close OE via Manager tasks or stop your Automatic compaction machine can take place.

    -Disable e-mail scanning in your antivirus application. It can cause this corruption (as well as loss of messages) and offers noadditional protection:

    Why you don't need your anti-virus to scan your email
    http://thundercloud.NET/infoave/tutorials/email-scanning/index.htm

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

  • (outlook 2003) send/receive emails

    Why do I continue to receive the same emails over and over again whenever I click on send/receive? This does not occur when I access emails through my ISP

    Probably because you have an anti-virus application integrated with Outlook analysis your mail - uninstall, reboot, reinstall * without * the outlook integration

  • Send/receive the constant of the blackBerry Curve 8330 Smartphone

    My unit is constantly send and receive.  No running applications, browser opens Favorites, tried to take the battery out several times and leave it outside for long periods (4 hours), wiped the unit but still seems to be constantly send and receive.  Was curious about the free text comment in file/options/status within the Council of 8100.  Is there a value, it should be to and if so what? And how you need to change?  The only change I can think is a temporary test of internet radio, but the device was destroyed twice since then.

    In addition, I discovered that there are six lists size of database browser, whose 4 indicate a 0 / 0.0 K size.  One who is a 2 / 0.1 K and is a 31 / 728.9 K.  Not sure if it is of no relevance or what it takes to do this.

    Market now I hope that the correct Board.

    I know it makes no sense, but I took a picture with the camera and he stopped the constant of send/receive.  Must have been a coincidence with something else but... it works fine now.  I have add the app free ESPN around the same time so maybe something in the configuration it?

  • Smartphones from blackBerry Storm constantly sends / receives data

    My 9530 storm do not stop to show up and down arrows for data returning/send/receive for hours at a time. They Flash on and outside, as if searching for data until the phone overheating and or completely drains the battery. I deleted the applications that use the GPS or update my sites, but it still happens. Short of wiping the phone and reconstruction does anyone have suggestions?

    CJ

    You should consider reinstalling or updating the operating system of your BlackBerry phone.

  • Cannot send/receive mail in the Windows Mail app on my laptop only

    I can't send or receive emails in Windows 8 on my laptop as he repeats to me in the upper right: "'* address email is removed from the privacy * is not available" (where xxx is my name). " I also have the Hotmail app on my iPhone and Android phone and they both signed and receive mail fine. I can even use my SkyDrive app very well on my laptop. Only the mail is affected.

    I rebooted to see if something had to be refreshed, but it made no difference. Anyone has an idea why this error and the inability to send/receive mail my mail?

    Hello

    Thank you very much for answering. I managed to settle the question, not that I know what it is. This is the only laptop among the many features that I sync with mail Outlook.com. I ended up going in the settings of the Mail application, off 'Synch Mail' and then I went back in the settings and turned on Synch Mail.

    Email stuck in my Outbox sent immediately and new messages have arrived. FIX :-)

    Some people do not like the Windows Mail application (it may not meet their most demanding needs), but I like it. I rarely use my MS Outlook more as it seems very small and crowded, by comparison. I love getting the full screen on my laptop to see what I just want to see, without toolbars and taskbars fly screen real estate.

    Sorry for the rant and thanks again for the reply.

    Best regards
    Brian.

  • How to customize the status bar, to see the send/receive status bar

    I have TB 24.4.0 on computers both Win 7 and Win Vista.
    On the installation of Win 7, I can (usually *) see email send/receive progress in the lower-left corner of the status bar (for example "Inbox to check for new messages", then POP3 for my various accounts etc.). I also see a green progress downstairs bar right when messages are sent or received. On this one, I also see the number of messages in each folder, extreme right (no read: # and Total: #).
    On the installation of Vista, numbers no read and Total are below on the left, but when I send and receive my email, there is no similar progress message (and no indication that the send/receive is actually at work, unless I get a new email).
    I would like to be able see the two send/receive status and the progress bar send/receive in the status bar. How can I do this? No read/Total numbers lower-left (instead of at the bottom right) block this?
    (* As in the past, even on my Win 7 installation, sometimes send/receive status disappears from the status bar - and I think that in this case no read/Total numbers to the left switch - but it didn't happen for a while. Why is it?)
    I can add screenshots if this will help.
    Forward advice or solutions. Thank you.

    See if you have the add on Adblocker Plus installed on the problem system. If so turn it off and restart Thunderbird. This add on is known to cause this problem.

  • I have a 6 s with Verizon iPhone. Can I send/receive calls (using this service and calls on other devices functionality) on my iPhone 5s, who was with AT &amp; T service, but has no service now since I switched to Verizon?

    I have a 6 s with Verizon iPhone. Can I send/receive calls (using this service and calls on other devices functionality) on my iPhone 5s, who was with AT & T service, but has no service now since I switched to Verizon?

    Note: I'm able to get two phones to ring with an incoming call, but the 5s consist not out. Whenever I dial a number, it says call failed.

    Do not dial a number. Try to choose a contact in the contacts App and tapping on telephone button.

    That said, I don't think that outgoing calls work on continuity since another iPhone. given that the iphone is designed to make calls through its own service.

    Document to support that you just did not mention calls from a secondary iPhone at all, it points to Mac, iPad and iPod touch, which leads me to believe that it won't work.

    It runs from devices such as iPads and Macs, who have no other way to place a cell call.

  • problems with sending/receiving messages

    For the last two weeks my iphone 6 s and my son 6 more have had problems with sending/receiving messages in the texts of the Group and regularly comes to a voicemail.  Messages are not at all or you may be able to receive them. Then last night on a group text between me and another user of iphone and a droid user messages were not all going through and an 'unknown' appeared on the screen of the droid users as if this person has attempted to send a message to our group text but nothing was there.  Iphone users could not see it.  This morning - messages still does not go through the text of the group or on one.  Any ideas?

    SMS texts are a function of carrier

    Control an upgrade of the carrier

    If the droid user used an iPhone before having them their registration number

    Also check with support carrier technique

  • Dynadock U3 - Ethernet does not - send/receive flashing every 3 seconds

    My wife uses a Dynadock with a spectrum of XP.
    Ethernet worked fine when I first put in place, but I just noticed the wired connection does not work (only works with wireless).

    Send & receive lights on n/w Dynadock port flash every ~ 3 seconds, the Windows port & alternate state between Enabled & cable disconnected.

    Not sure how long the wired connection has not worked, but my scale did spend a couple of months to Win 8.1. At the time I had upgrade the drivers to get the video via the Dynabook work. I checked & Win network drivers have been also upgraded in this framework.

    Have seen a few other posts on uninstalling/reinstalling the drivers (done) & case where the icon network in the device driver has a warning '?' (says "device is working properly" in my case).

    Recommendations, or suggestions for a further diagnosis?

    Hello
    In my view, the question appears due to the update system 8.1 Win.
    You will need configure the network in the network adapter properties:
    To connect to the network via an Ethernet network cable, connect one end of a network
    cable to the Ethernet (RJ-45) the dynadock port and the other end to your network for the great
    performance of network access.

    To set the properties of the network to the Ethernet adapter:
    8.1 Windows, move the mouse pointer and click the icon at the bottom left of the screen to go to the
    Apps for display and then click on Control Panel-> network and Internet-> tasks-> change map settings and display the status of network.

    In the network connections folder, double-click the icon of the s dynadock Ethernet adapter connection.
    which is indicated by dynadock Ethernet. This will open the local area network connection properties window for you
    Configure network settings as required depending on your network environment.

    Note: The icon to connect to the Local network in the system tray/Notification area does not show a connection. Open network connections to display the Ethernet connection.

    I also found another thread on the same topic:
    http://forums.computers.Toshiba-Europe.com/forums/thread.jspa?threadID=70771

  • I can't send / receive text Messages on my phone my husband track 6s iphone

    I can't send / receive text Messages on my phone my husband track 6s iphone.

    Contact your operator. SMS and MMS messaging are characteristic of the carrier.

  • missing number of iPhone on iPad send / receive

    My conversations SMS do not appear on my iPad and iPhone. When I go into settings > send / receive on my new iPad, my iPhone number does not appear. Why?

    On your iPhone, go to settings > Messages > text Message transfer and make sure your iPad is turned on.

Maybe you are looking for

  • It is possible to burn a multisession CD or a CD - RW on an iMac running El Capitan 10.11.1

    I was able to burn a multisession CD or a CD - RW on my iMac El Capitan 10.11.1 running. I know that this was possible in older versions of the operating system. It is not possible in El Capitan?

  • IdeaPad P400 - display does not work.

    Hello, I have a P400 Ideapad, display is not working properly, it will stay black. But if I move the screen forward or backward, it works again, as if she had a bad connection. Especially if I'm pushing on a corner of the laptop, it works perfectly.C

  • Automatic indexation 2D array in the loop For - what is happening?

    I found many sources dealing 1 d tables in a loop For or a While loop, using automatic indexing, but nothing on the tables of higher order. I work with a program that feeds a 2D array in a loop (see table).  From what I see, it looks like this the re

  • Problems with msvbvm60.dll

    When I open the Control Panel, under appearance and themes, and I click on display in shooters of boredom, I get the following message: "this application has failed to start because msvbvm60.dll was not found." Can someone tell me what I need to plea

  • Download dvd to you tube dell Windows 7

    I have windows media, is it possible to download a dvd from my windows media directly to my u tube channel player