protected synchronized boolean write ( byte [ ] bytes ) { mConnectionLock . readLock ( ) . lock ( ) ; boolean success = true ; try { if ( isConnected ( ) ) { Log . v ( TAG , "Writing " + bytes . length + " to socket" ) ; mOutStream . write ( bytes ) ; } else { Log . w ( TAG , "No connection established, could not send anything." ) ; success = false ; } } catch ( IOException e ) { Log . w ( TAG , "Unable to write CAN message to Network. Error: " + e . toString ( ) ) ; success = false ; } finally { mConnectionLock . readLock ( ) . unlock ( ) ; } return success ; }
Writes given data to the socket .