Saturday, April 16, 2011

Display UUID of disks in Debian

Jaya Srila Prabhupada.

The command is: blkid

Jaya Sri Sathguru Bhagawan Sridhara Swamy Maharaja

Wednesday, April 13, 2011

What I learned the last week

Jaya Srila Prabhupada (most merciful savior)

TCP/IP programming in Windows.

Started with my own classes ServerSocketFactory and ClientSocketFactory which encapsulated the TCP/IP api of .NET. One more class NetworkSocket encapsulated the Socket api of .NET

Learned by mistakes.

First mistake was that I bound the listening socket to the localhost (SockAddress.Local) instead of binding to SocketAddress.Any

I learnt that one can chain readers like this:
new StreamReader(new NetworkStream(new Socket(adr_family, sock_type, proto_type)));

Now writing or reading from a reader object writes to the underlying stream!

The client used to ask for something by sending a string of characters with a newline trailing and I was trying to receive it without expecting a newline. Sometimes it was the other way round. Both should settle on one scheme. When we call the 'ReadLine' method on a StreamReader, it doesn't return until it sees a newline. The ReadLine method always returns a string that was read from the stream (here socket).

What happens when you are trying to read from a connected socket but the remote socket is closed, the Receive method (analogous to 'recv' in unix socket programming) returns immediately with zero bytes. Analogously if we are using the 'ReadLine' method on a StreamReader of a socket, the ReadLine method returns immediately with a null value (and NOT a null string).

Jaya Sathguru Bhagawan Sri Sridhara Swamy maharaja.