Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

DatagramConnection limitation in Blackberry?

In case of DatagramConnection, it requires the connection string o be like "datagram://hostSmiley Tongueort"


if this is the case, the connection will be bound to specific ip address. On top of that there is a limtation of maximum limit datagram connections open at any instant ( I think it is 15).


Based on my knowledge on other languages related to datagram, packet should carry the host details. But coonection should just push it onto the network. As there is know packet concept here, connection itself will be bound to specific IP.


My requirements is to Send a datagram packet to multiple ip addresses and listen on a fixed port on a different connection. If I create a connection to send the packet to multiple addresses, it reaches the maximum limit. I got to know that we cannot even close the connection after sending the packet to receive the responce from the destination host.


Can we create a DatagramConnction without making it bound to IP Address? or any other better way to solve my problem?


Thanks in advance for any suggestions.

Posts: 402
Registered: ‎11-26-2010
My Device: Torch

Re: DatagramConnection limitation in Blackberry?

From the docs:


"A datagram connection can be opened in a "client" mode or "server" mode. If the "//{host}" part is missing then the connection is opened as a "server" (by "server", we mean that a client application initiates communication). When the "//{host}" part is specified, the connection is opened as a "client"."


So it seems that you have to add the //{host} part to make requests.


I haven't used it but there is a method newDatagram(byte[] buf, int size, String addr) which allows address param at the end. Furthermore if you have a datagram object you can set address to it:

http://www.blackberry.com/developers/docs/5.0.0api/javax/microedition/io/Datagram.html - check the setAddress method. 


This is just something i found and I don't know if it would work at all!

Press the button to give kudos if I helped you Smiley Happy
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: DatagramConnection limitation in Blackberry?

Thanks for the hints.


I implemented my connections using the Datagram server method.


i.e DatagramConnection myConnection = (DatagramConnection) connector.open("datagram://:8000");


Datagram myDatagram = myConnection.newDatagram(buf, buf.length, address); where address is ipSmiley Tongueort.


It works fine if I send around 20 datagrams to it and wait for the responce to read the responce for my datagrams. However if I send more than 20, i.e around 50 datagrams i just dont receive any responces.


Any limit in blackberry related to this?