• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2Me datagram connection with multicast socket server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , i am creating a pda client with datagram connection (for receiving information only) to be connected to a Udp server with multi-cast ip address and port number. Is it possible to connect between a datagram connection(J2ME UDP) to a J2SE(udp multicast socket connection) ?

below is the pda client connection

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
import java.util.*;

public class testPDA extends MIDlet implements CommandListener
{
private Command exitCommand,nextCommand;
private Display display;
private Form screen;
private StringItem nameItem;
private Vector client1;
private Datagram receiveDatagram;
//private DatagramClientHandler client;
private DatagramConnection dc;

public testPDA()
{
display = Display.getDisplay(this);

exitCommand= new Command("Exit", Command.EXIT,2);
nextCommand = new Command("Next",Command.OK, 2);

screen = new Form("Welcome to Pda");
nameItem= new StringItem("" , "Retrieving info..");
screen.append(nameItem);

client1 = new Vector();

}

public void startApp() throws MIDletStateChangeException
{
try
{
display.setCurrent(screen);
connect();

}
catch(Exception o)
{

}
}

public void pauseApp()
{

}

public void destroyApp(boolean con)
{
}


public void commandAction(Command c, Displayable s)
{
if(c == exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if(c==nextCommand)
{
try
{
connect();
}
catch(Exception e)
{
}

}
}

private void connect() throws Exception
{

try
{
dc = (DatagramConnection)
Connector.open("datagram://230.0.0.1:9000");


receiveDatagram = dc.newDatagram(dc.getMaximumLength());

String retval="";

try
{
dc.receive(receiveDatagram);
byte[] data = receiveDatagram.getData();

retval = new String
(data,0,receiveDatagram.getLength());




}




catch(IOException oe)
{
System.out.println(oe.toString());
}








}
catch(Exception e)
{
e.printStackTrace();
}

finally
{
dc.close();
}

}

}
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Jackson Jackson"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic