To update DynDNS hostname from TC65i code like this needs to be used and the attached Base64.java for Base64 encoding
public String updateDynDNS()
{
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String response=null;
String url = "
http://members.dyndns.org/nic/update?system=dyndns&hostname=YOUR_HOSTNAME&wildcard=OFF";
try {
System.out.println("requestIPAddress(): connectie wordt geopend");
c = (HttpConnection)Connector.open( url );
c.setRequestMethod("GET");
c.setRequestProperty("Host","
members.dyndns.org");
c.setRequestProperty("Authorization","Basic "+String.valueOf(Base64.encode("YOUR_USERNAME:YOUR_PASSWORD".getBytes()))+"\"");
c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
// Getting the InputStream will open the connection
// and read the HTTP headers. They are stored until
// requested.
System.out.println("requestIPAddress(): response code: "+c.getResponseCode());
is = c.openInputStream();
// Get the length and process the data
System.out.println("requestIPAddress(): inputstream is ok");
if (is != null)
{
System.out.println("requestIPAddress(): reading inputstream");
int ch;
while ((ch = is.read()) != -1) {
//System.out.print( (char)ch );
baos.write(ch);
}
response = new String(baos.toByteArray());
//System.out.println(response);
}
else System.out.println("requestIPAddress(): geen inputstream verkregen");
}
catch ( Exception ioe )
{
System.out.println("Fout: "+ioe.getMessage());
ioe.printStackTrace();
}
finally
{
try
{
if(baos != null) {
baos.close();
//baos = null;
}
if (is != null) {
is.close();
//is = null;
}
if (c != null)
{
c.close();
//c = null;
}
}
catch (IOException ioe )
{
System.out.println("Fout: "+ioe.getMessage());
ioe.printStackTrace();
}
}
return response;
}
Kind regards,
Timo Medvedev
------------------------------
TC65i programming, source codes and training ->
http://www.tc65.nl