Welcome!

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

Reply
BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem sending udp datagram

Can you verify what line of code is throwing the exception?  Is it the Connector.open method?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: Problem sending udp datagram

The open method not throws any exception, the exception is launch when i execute the send(Datagram data) method of UDPDatagramConnection.
BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem sending udp datagram

[ Edited ]
Please try using the udp:// protocol header in the Connector.open method instead of datagram://.  Alternatively you can try specifying an incoming and outgoing port in your URL.  Example:  datagram://192.168.0.1:5000;6000
Message Edited by MSohm on 09-17-2008 01:24 PM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: Problem sending udp datagram

i have test it and the result is the same
BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem sending udp datagram

Can you verify what you are trying to accomplish?  Then I may be able to point you to a working sample.  Are you trying to:

 

a) Create a UDP connection.

b) Send a datagram via SMS.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: Problem sending udp datagram

Hi, i am trying to create a udp connection, thats the code that i am test

 

 

UDPDatagramConnection prueba=(UDPDatagramConnection)Connector.open("datagram://comm.hi.inet:5060"); String cadena="Hola soy un datagrama"; byte [] bytes=cadena.getBytes(); Datagram dgram= prueba.newDatagram(bytes,bytes.length); dgram.setAddress("datagram://comm.hi.inet:5060"); prueba.send(dgram);

 

UDPDatagramConnection prueba=(UDPDatagramConnection)Connector.open("udp://comm.hi.inet:5060"); String cadena="Hola soy un datagrama"; byte [] bytes=cadena.getBytes(); Datagram dgram= prueba.newDatagram(bytes,bytes.length); dgram.setAddress("datagram://comm.hi.inet:5060"); prueba.send(dgram);

 

 

 

UDPDatagramConnection prueba=(UDPDatagramConnection)Connector.open("datagram://comm.hi.inet:5060"); String cadena="Hola soy un datagrama"; byte [] bytes=cadena.getBytes(); Datagram dgram= prueba.newDatagram(bytes,bytes.length); dgram.setAddress("udp://comm.hi.inet:5060"); prueba.send(dgram);

 

 

 

UDPDatagramConnection prueba=(UDPDatagramConnection)Connector.open("udp://comm.hi.inet:5060"); String cadena="Hola soy un datagrama"; byte [] bytes=cadena.getBytes(); Datagram dgram= prueba.newDatagram(bytes,bytes.length); dgram.setAddress("udp://comm.hi.inet:5060"); prueba.send(dgram);

 

and the same result in all (i test it with the ip address also) .

 

BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem sending udp datagram

You shouldn't need to set the address of the Datagram.  Do you receive the exception if you don't set the address?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 69
Registered: ‎08-13-2008
My Device: Not Specified

Re: Problem sending udp datagram

[ Edited ]

Hi,

 

yes, thats the problem. now i can send datagrams, but i still have a problem, if i do that it works to send

 

 

UDPDatagramConnection socketEnvio=(UDPDatagramConnection)Connector.open("datagram://"+pkt.getIpAddress()+":"+pkt.getPort()); Datagram dgram=socketEnvio.newDatagram(pkt.getData(), pkt.getLength()); socket.send(dgram);

 

 but i need to open the socket to receive and transmit in the same port.

 

 

UDPDatagramConnection socketEnvio=(UDPDatagramConnection)Connector.open("datagram://5060"); //here i need to put the addres to the datagram to send to the destination host but if i use the setAddress() it throws the exception socket.send(dgram);

 

 

 

 so any knows what the format of the address to put in the datagram, i test that if i put "datagram://" it throws an exception of bad address but i i only put "//comm.hi.inet:5060" i throws bad digit, any idea?

 

 

thanks

Message Edited by jllarraz on 09-22-2008 07:58 AM
Highlighted
BlackBerry Development Advisor
Posts: 15,724
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problem sending udp datagram

The datagram will take the address of the connection used to create it.  You are not able to change it.

 

Opening a new connection with your new address should work though.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 35
Registered: ‎01-07-2009
My Device: Curve 8320

Re: Problem sending udp datagram

I am using "(UDPDatagramConnection)myclient.newDatagram(data, len)" to create a datagram, but datagram.getAddress() returns null. If I use Datagram.setAddress(url), then myclient.send(Datagram) will throw out "Bad address".

Does this mean the before (UDPDatagramConnection) Connector.open(url) failed somewhere? It throws no exception and doesn't equals to null.

How can I make sure if the UDPDatagramConnection has been created really OK?