I'm just trying to write my first application in java.
The Application connects to my VDR (Media Center) and send's SVDR Commands like "CHAN +" so seitch channel up.
Now i'm trying to set the Volume, or get the EPG Date, but for this i need to get incoming traffic from the Server.
When i send "VOLU" to the Server, it responses with the Volume set atm.
The application works great at the Moment (Channel up, Channel down and 0 to 9 implemented right now)
could you help me how to get the answeres from the server?
here's my code from the client.java:
Using java Syntax Highlighting
- package com.e2esp.socket.test;
- import android.content.SharedPreferences;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.OutputStreamWriter;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.net.InetAddress;
- import java.net.ServerSocket;
- import java.net.Socket;
- import android.preference.PreferenceManager;
- import android.util.Log;
- public class TCPClient implements Runnable {
- public static final String DEFAULT_SERVERIP = "192.168.178.22";
- public static final int SERVERPORT = 2001;
- public static String message = "";
- public SharedPreferences prefs;
- public static final String PREFS_NAME = "MyPrefsFile";
- public void run() {
- try {
- /*SharedPreferences settings = this.
- public String server = settings.getString("SERVERIP","DEFAULT_SERVERIP");
- settings.*/
- InetAddress serverAddr = InetAddress.getByName(DEFAULT_SERVERIP);
- //InetAddress serverAddr = InetAddress.getByName();
- Log.d("TCP", "C: Connecting...");
- Socket socket = new Socket(serverAddr, TCPClient.SERVERPORT);
- //String message = "CHAN +\n";
- try {
- Log.d("TCP", "C: Sending: '" + message + "'");
- PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);
- BufferedReader in = new BufferedReader(socket.getInputStream());
- out.println(message);
- Log.d("TCP", "C: Sent.");
- Log.d("TCP", "C: Done.");
- } catch(Exception e) {
- Log.e("TCP", "S: Error", e);
- } finally {
- socket.close();
- }
- } catch (Exception e) {
- Log.e("TCP", "C: Error", e);
- }
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4

