04-05-2011 06:56 AM
In case of DatagramConnection, it requires the connection string o be like "datagram://host
ort"
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.
04-05-2011 07:36 AM
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
This is just something i found and I don't know if it would work at all!
button to give kudos if I helped you 04-12-2011 09:55 AM
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 ip
ort.
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?