User: amity
These are the most recent forum messages posted by amity:
Re: Is it possible to read http:// url via socket protocol ?
If I use Port(80,8080 and 443) then only my SocketConnection is set up(showing in N/W monitor) otherwise no connection is showing.
Is it possible to read http:// url via socket protocol ?
package connection;
import display.Show;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.io.SocketConnection;
impo rt midlet.GCFMIDlet;
public class Socket{
String url="socket://www.globallogic.com:443";
//St ring url="http://www.lambenttek.com:80";
SocketConnection scon=null;
HttpConnection hcon=null;
InputStream is=null;
OutputStream os=null;
DataInputStream din=null;
DataOutputStream dout=null;
StringBuffer buf= new StringBuffer();
StringBuffer header = new StringBuffer();
public Socket(GCFMIDlet midlet){
try{
//make a connection to server
SocketConnection scon = (SocketConnection) Connector.open(url);
//System.out.println("C onnection : "+scon);
// set application-specific options on the socket. Call setSocketOption to set other options
scon.setSocketOption(SocketConnection.DELAY , 1);
scon.setSocketOption(SocketConnection.KE EPALIVE,1);
scon.setSocketOption(SocketConne ction.LINGER,1);
scon.setSocketOption(Socket Connection.RCVBUF,8000);
scon.setSocketOptio n(SocketConnection.SNDBUF,8000);
// send something to server
os = scon.openOutputStream();
dout = new DataOutputStream(os);
//os.write("GET /indus_diff/index.shtml HTTP/1.1 \r\n".getBytes());
dout.writeChars("GET /indus_diff/index.shtml HTTP/1.1\n");
// dout.writeChars("User-Agent : Profile/MIDP-2.0 Configuration/CLDC-1.0\n");
// dout.writeChars("Content-Language : en-US\r\n");
// ...
Socket connection in CLDC
Hello,
I have write a sample program to read
the content of a URL via SocketConnection. I got success to make a socket connection with server. which I had conform to seem in n/w monitor which i enabled previously.
But the problem is that nothing should ...