I am trying to develop TCP/IP communication application in Android using Java via AsynchronousSocketChannel. I am getting symbol not found error for my private data members in my read handler. I have no prior experience in Android App development or in Java but I worked extensively in C++. The program is based on template from by C++ Boost.Asio application which is working properly. OS - Windows 10 64-bit Target Platform - Android Things Raspberry Pi 1.08
public class Ethernet {
private String ip;
private int portNo;
private Queue<String> recvQueue, sendQueue;
private InetAddress address;
private String readData;
private InputStream in;
private OutputStream out;
private AsynchronousSocketChannel socket;
private boolean socketAlive, connectionInProgress;
private ByteBuffer readBuffer;
Ethernet(String ip, int port) {
if (port > 65535 && port < 1024)
port = 6666;
this.ip = ip;
this.portNo = port;
this.socketAlive = false;
this.connectionInProgress = false;
this.readBuffer = ByteBuffer.allocate(8192);
}
private void recieveDataSocket(){
this.socket.read(this.readBuffer, null, new CompletionHandler<Integer, Object>() {
@Override
public void completed(Integer result, Object attachment) {
if (result < 0) {
this.socketAlive = false; //Error
}
else if (this.readBuffer.remaining() > 0) {
// repeat the call with the same CompletionHandler
this.socket.read(this.readBuffer, null, this);//Error
}
else {
// got all data, process the buffer
}
}
@Override
public void failed(Throwable e, Object attachment) {
// handle the failure
}
});
} }
Error :
error: cannot find symbol
this.socketAlive = false;
^ symbol: variable socketAlive error: cannot find symbol
else if (this.readBuffer.remaining() > 0) {
^ symbol: variable readBuffer error: cannot find symbol
this.socket.read(this.readBuffer, null, this);
^ symbol: variable readBuffer error: cannot find symbol
this.socket.read(this.readBuffer, null, this);
^ symbol: variable socket error: cannot find symbol
eth.disconnect();
^ symbol: method disconnect() location: variable eth of type Ethernet 5 errors