Skip to main content

Posts

Showing posts from June, 2013

Pipe is not always for smoking

pipes with IO & Networking Is a way of communication, connecting two ends "program to a file , program to a program ...etc".as if a person calling another between those two person there exist a pipe. For IO one end is a file, where as for networking both ends are programs basic operation open():inputStream, for opening a connection. A person dailing a number, the other end pick up close(), for closing this connection, one person hang up write(byte[] bufferToWrite,int numOfByteToWrite):numOfActuallyWriten. A person talking read(byte[] bufferToReadIn,int numOfByteToRead):numOfBytesRead. A person listening read() operation is a blocking one, so can use available() to check if in the input stream there exist any data to read before do a blocking read. can also synchronize between the two ends by adding a Buffer for file: FileInputStream --> BufferedInputStream --> DataInputStream BufferedInputStream is used to read stream of bytes, if want to distinguish &