//Use an unrestricted filter.
String filter = "*";
String url = "socket://:" + m_sSocketPort;
ServerSocketConnection ssc = null;
try
{
//Open the connection.
ssc =
(ServerSocketConnection) Connector.open(url);
System.out.println("/* Already Open the connection!");
//Discover the system-assigned port.
url = "socket://:" + ssc.getLocalPort();
//Register the connection now. The AMS will
//remember the registered URL even when the MIDlet
//is not active.
PushRegistry.registerConnection(url,
m_sMidletClassName, filter);
System.out.println("/* Already Register the connection now!" +
url);
//Now publish the push URL. We can use an HTTP
//POST or a socket or datagram for this.
String purl;
purl = "socket://" + ssc.getLocalAddress() +
":" + ssc.getLocalPort();
publishInboundConnection(purl, m_sMidletClassName);
} |