dear sir
i have this part of a code that a mobile send input coordinate (startx and starty) to a server using socket
how can i modify it so that the line in main class
System.out.println("startx1"+startx);
will display the sended value
and how to modify the socket code in order to send image from server to mobile
with best regard
public class test extends Component {
public static void main(String args[]) {
connect();
System.out.println("startx1"+startx);
}
public static void connect() {
try {
System.out.println("S: Connecting...");
ServerSocket serverSocket = new ServerSocket(12344);
toClient = serverSocket.accept();
System.out.println("S: Connected");
Thread desktopServerThread = new Thread(){
public void run(){
while(true){
try {
in= new BufferedReader(new InputStreamReader(toClient.getInputStream()));
String str;
if (!(str=in.readLine()).equals("") | !str.equals(" "))
System.out.println("C: '" + str);
int b = str.indexOf('d');
String startpt = str.substring(1, b);
int bbb=startpt.indexOf(',');
String bx = startpt.substring(0, bbb);
String by = startpt.substring(bbb+1);
startx=Float.valueOf(bx.trim()).intValue();
starty=Float.valueOf(by.trim()).intValue();
String destpt = str.substring(b+1);
System.out.println("Sending Message Succesful"+" s "+startpt+" d "+destpt);
System.out.println("xx "+startx+" yy "+starty);
} catch(Exception e) {
System.out.println("S: Error");
e.printStackTrace();
break;
}
}
}
};
desktopServerThread.start();
} catch (Exception e) {
System.out.println("S: Connection Error");
e.printStackTrace();
}
}
}

Reply With Quote



