Hello ,
How can i connect to a TcpServer(using ip & port) with J2ME ? i want to send a request to the server and get responses !
Hello ,
How can i connect to a TcpServer(using ip & port) with J2ME ? i want to send a request to the server and get responses !
My Problem solved using this code :
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
StreamConnection connection = (StreamConnection)
Connector.open("socket://IP:Port");
PrintStream output =
new PrintStream(connection.openOutputStream());
output.println("Request");
output.flush();
InputStream in = connection.openInputStream();
int ch;
String recx;
while( ( ch = in.read() ) != 13 )
{
recx = recx + (char)ch;
}
in.close();
output.close();
connection.close();