aspose file tools*
The moose likes Java Micro Edition and the fly likes J2Me datagram connection with multicast socket server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "J2Me datagram connection with multicast socket server" Watch "J2Me datagram connection with multicast socket server" New topic
Author

J2Me datagram connection with multicast socket server

eric jackson
Greenhorn

Joined: Feb 03, 2005
Posts: 3
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();
}

}

}
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

"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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: J2Me datagram connection with multicast socket server
 
Similar Threads
I don't know what to do!
Please help in reading a file
J2ME, servlet and database help..
Getting Live Data Problem Problem
System Information Code not running