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
Contributor
floydian
Posts: 16
Registered: ‎10-12-2009
My Device: Not Specified

General socket error when providing domain name instead of IP

Hi,

 

does datagram connection support DNS resolver? I am trying to send a single datagram in the following way:

 

UDPDatagramConnection connection = connection = (UDPDatagramConnection) Connector.open("datagram://;interface=wifi");
Datagram datagram = datagram = new DatagramBase();

datagram.setAddress("wp.pl");
connection.send(datagram);

 

It always results with "java.io.IOException: General socket error" when sending.

However, if I insert corresponding IP address instead of the domain in the setAddress method it works very well.

 

If I cannot pass a domain name as a parameter in this function, is there a way to obtain the IP address of that domain programatically?

 

Thanks,

Adam

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,521
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: General socket error when providing domain name instead of IP

You need to specify an IP address when making a UDP connection. 

 

The BlackBerry API set does not have any classes to look up an IP address directly.  However, you could make a socket or HTTP connection to your server using its DNS name and have it return its IP 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
Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: General socket error when providing domain name instead of IP

setAddress only takes IP address. It does not take domain name.

 

If you want to translate domain name to IP address, you can use jdnp (http://delta.affinix.com/jdns/). Giving a DNS server name, you can translate any domain name to its IP address.

 

Please use plain text.
Visitor
sumant2000
Posts: 1
Registered: ‎08-26-2011
My Device: 9800
My Carrier: airtel

Re: General socket error when providing domain name instead of IP

Please let me know how to make a socket or HTTP connection to server using it's DNS name, so that server can return it's IP Address?
Please use plain text.
Contributor
satyagrwl
Posts: 12
Registered: ‎06-16-2011
My Device: 9000
My Carrier: Vodafone

Re: General socket error when providing domain name instead of IP

Hi MSohn

 

Thanks for the reply. Yes we can create any socket or HTTP connection using DNS name. Then that connection objects are keeping the IP addresses as protected variables.

 

As you told it returns its address, No its not returning its IP addressed.

Can you please suggest any way to get the IP address.

 

Thanks...

Please use plain text.