Wednesday, 1 February 2012

Redirect Standard stream in C

Redirecting std input or output to any device or file is generally provided by all operating systems. The redirection is done generally using ">" for output to and "<" for input from a device. e.g.

$ gcc ./a.out > file

redirects the output to "file". The same can be done for input.
  But the redirection is not supposed to be done by OS only. Languages like C also provide some library functions to support this functionality. Consider an example for function freopen(), used for the same purpose.

freopen("file.txt","w",stdout);
....
....

 Now all the standard output will be streamed to file.txt.

Wednesday, 4 January 2012

Share your data using Python

     Python provides a simple way to share your data to some person in the network. Following are the steps for sharing the files :

Step 1: Go to the directory, which you want to share using 'cd' command.
Step 2: Create a simple HTTP server,just running the command : 'python -m SimpleHTTPServer 7000'
Step 3: That's it, the server is running on port 7000 (you can specify your own port number)
Step 4: Tell the person with whom you want to share, the IP address of yours.
Step 5: Just open your web browser and type URL as ' <IP address> : <Port number>' and Hit      <Enter>.
     You will see all the files in the current directory.

Thursday, 10 November 2011

What is Virtual Machine ?

        A virtual machine is a software implementation of a computing environment in which an operating system  or program can be installed and run.
Que :   How does it work ?     
 Ans :   The virtual machine typically emulates a physical computing environment, but requests for CPU, memory, hard disk, network and other hardware resources are managed by a virtualization layer which translates these requests to the underlying physical hardware.
          VMs are created within a virtualization layer, such as a hypervisor or a virtualization platform that runs on top of a client or server operating system. This operating system is known as the host OS. The virtualization layer can be used to create many individual, isolated VM environments.
       Typically, guest operating systems and programs are not aware that they are running on a virtual platform and, as long as the VM's virtual platform is supported, this software can be installed in the same way it would be deployed to physical server hardware. For example, the guest OS might appear to have a physical hard disk attached to it, but actual I/O requests are translated by the virtualization layer so they actually occur against a file that is accessible by the host OS.
Que : Why to use VM ?
Ans : Virtual machines can provide numerous advantages over the installation of OS's and software directly on physical hardware. Isolation ensures that applications and services that run within a VM cannot interfere with the host OS or other VMs. VMs can also be easily moved, copied, and reassigned between host servers to optimize hardware resource utilization. Administrators can also take advantage of virtual environments to simply backups, disaster recovery, new deployments and basic system administration tasks. The use of virtual machines also comes with several important management considerations, many of which can be addressed through general systems administration best practices and tools that are designed to managed VMs.

Tuesday, 18 October 2011

Push Mail


             Push email utilizes a mail delivery system with real-time capability to “push” email through to the client as soon as it arrives, rather than requiring the client to poll and collect or pull mail manually. With a push email smartphone, for example, the client’s mailbox is constantly updated with arriving email without user intervention. Smartphones announce new mail arrival with an alert.
                Push email differs from conventional email systems that are “pull” oriented. Usually, when email is sent, it arrives at the recipient’s Internet Service Provider's (ISP’s) mail server, where it is held for collection. It might instead arrive at a website server, if the email is Web-based. Either way, email remains on the mail server until the recipient uses an email program to poll the mail server. If new mail is present, the email client “pulls” the mail to the client’s computer. The difference between this scheme and push email is that, with push email, the mail is pushed through to the client without waiting for polling.
BlackBerry was the first personal digital assistant (PDA) to offer push email and gained near-instant success as a result. Today, many devices have incorporated push email, and its popularity continues to grow. Some of the products that have incorporated push email include Chatteremail for Treo, Nokia Intellisync Wireless Email, Roadsync, and Sony Ericsson phones.

Wednesday, 10 August 2011

memccpy function in C : not memcpy !!!

Function name : memccpy (copy bytes in memory)

Syntax :

 #include <string.h>

void *memccpy(void *restrict
s1, const void *restrict s2,int c, size_t n);

What it does ?

The memccpy() function shall copy bytes from memory area s2 into s1, stopping after the first occurrence of byte c (converted to an unsigned char) is copied, or after n bytes are copied, whichever comes first. If copying takes place between objects that overlap, the behavior is undefined.
What is Returns ?

The memccpy() function shall return a pointer to the byte after the copy of c in s1, or a null pointer if c was not found in the first n bytes of s2.
memccpy v/s memcpy :

         It's simple. Just the extra c .You can specify when to stop the copy;that is,when the char specified by 'c' in the source string s2 is reached.

Check out ..\m/