Hello ,
I have a strange problem
I'm trying to send string using TCP client .
I can see the string that I want to send is in the right length (about 15 chars) , but on the server side I only get the first char....
I thought the prboem is in the server code (which is not) so I have also check with WireShark - agian I only get the first char
what is the problem?
private void initViews() {
txtBarcodeValue = findViewById(R.id.txtBarcodeValue);
surfaceView = findViewById(R.id.surfaceView);
btnAction = findViewById(R.id.btnAction);
btnAction.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
if (intentData.length() > 0) {
Thread thread = new Thread(new Runnable() {
@override
public void run() {
try {
String server_ip = "My.Server.IP";
int server_port = 8888;
String messageStr = intentData + "!" + Number+"!"+ name+"!";
Socket clientSocket = new Socket(server_ip, server_port);
clientSocket.setSoTimeout(2000);// I thought maye this is the problem - didn't help
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
outToServer.writeBytes(messageStr + 'n');
ServerReply = inFromServer.readLine();
///need to write a function that check the response
clientSocket.close();
} catch (Exception e) {
e.printStackTrace();
}
finally {
}
}
});
thread.start();
}
Toast.makeText(getApplicationContext(),ServerReply,Toast.LENGTH_LONG).show();
// finish();
}
});
}
anyone?
Thanks ,
I have a strange problem
I'm trying to send string using TCP client .
I can see the string that I want to send is in the right length (about 15 chars) , but on the server side I only get the first char....
I thought the prboem is in the server code (which is not) so I have also check with WireShark - agian I only get the first char
what is the problem?
private void initViews() {
txtBarcodeValue = findViewById(R.id.txtBarcodeValue);
surfaceView = findViewById(R.id.surfaceView);
btnAction = findViewById(R.id.btnAction);
btnAction.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
if (intentData.length() > 0) {
Thread thread = new Thread(new Runnable() {
@override
public void run() {
try {
String server_ip = "My.Server.IP";
int server_port = 8888;
String messageStr = intentData + "!" + Number+"!"+ name+"!";
Socket clientSocket = new Socket(server_ip, server_port);
clientSocket.setSoTimeout(2000);// I thought maye this is the problem - didn't help
DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
outToServer.writeBytes(messageStr + 'n');
ServerReply = inFromServer.readLine();
///need to write a function that check the response
clientSocket.close();
} catch (Exception e) {
e.printStackTrace();
}
finally {
}
}
});
thread.start();
}
Toast.makeText(getApplicationContext(),ServerReply,Toast.LENGTH_LONG).show();
// finish();
}
});
}
anyone?
Thanks ,