EasyManua.ls Logo

Evolution Robotics ER1 - Page 111

Default Icon
170 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ER1 User Guide 10-25
ER1Client.java
return sendBuffer(s.getBytes(), s.length());
}
boolean sendBuffer(byte[] bytes, int size) {
if (_write_stream == null) {
//Global.applet.showDebug("No server connection so cannot send message!");
return false;
}
try {
_write_stream.write(bytes, 0, size);
_write_stream.flush();
}
catch (Exception ex) {
disconnect();
System.out.println(ex.toString());
return false;
}
return true;
}
public void disconnect() {
try {
if (_socket != null) {
_socket.close();
_socket = null;
_write_stream = null;
}
}
catch (Exception ex) {
System.out.println(ex.toString());
}
}
///////////////////////////////////////////////////////////////////////
// Helpers
///////////////////////////////////////////////////////////////////////
public void parseCommandLine(String[] args)
{
// Parse command line parameters.
int paramCount = args.length;
for (int i = 0; i < paramCount; ++i) {
// Check for quiet mode.
if (args[i].compareTo("-q") == 0) {
// quiet mode!
_verbose = false;
}
// Check for new host address.
else if (args[i].compareTo("-a") == 0) {
if (i >= paramCount - 1) {
System.out.println("ignoring -a flag with no address.");
}
else {
i++;
_address = args[i];
}
}
// Check for new host address.
else if (args[i].compareTo("-p") == 0) {
if (i >= paramCount - 1) {
System.out.println("ignoring -p flag with no port number.");
}
else {

Table of Contents