Hi,

I am trying to open SocketConnection in j2me midlet it works fine with sun emulator but does not work with nokia emulator, i am not getting any exception also.

I tried HttpConnection in nokia emulator which works fine then whats the issue with the socketconnection?


I am using netbeans ide : 6.7
j2me sdk 3.0
Symbian S60 3rd FP1 SDK

code :

DataInputStream dis = null;
DataOutputStream dos = null;

String str = "";

javax.microedition.io.SocketConnection sc = null;
try
{


sc = (SocketConnection)Connector.open("socket://whois.internic.net:43",Connector.READ_WRITE,true);

sc.setSocketOption(SocketConnection.DELAY, 1);
sc.setSocketOption(SocketConnection.KEEPALIVE,1);
sc.setSocketOption(SocketConnection.LINGER,5);
sc.setSocketOption(SocketConnection.RCVBUF,10000);
sc.setSocketOption(SocketConnection.SNDBUF,10000);


dis = sc.openDataInputStream();
dos = sc.openDataOutputStream();

String host = urlstring+"\n";


byte buf[] = host.getBytes();
dos.write(buf);


int c;

while ((c=dis.read())!=-1)
{
System.out.print((char)c);
str = str + (char)c;

}



}
catch (IOException ioe)
{

System.out.println(ioe.getMessage());

return ioe.getMessage();
}
finally
{
try { if(sc != null) sc.close(); } catch (IOException ignored) {}
try { if(dis != null) dis.close();} catch (IOException ignored) {}
}




return str;
}