• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

3SFE518 Computer System Organisation - Piping

Extracts from this document...

Introduction

Coursework for:

Computer System Organisation

3SFE518

Malshani Nanayakkara

2007020

CONTENTS

Introduction – About the Piping        3

Program Listing        4

Screenshots        7

ABOUT THE PIPING

        In order to be able to communicate between two terminals, pipes have been used. As pipes are FIFO structure (First In First Out), it is well suited to be used for such an application. Two pipes are created, one used to define a communication channel from the server terminal to the client and the other to define a communication channel from the client terminal to the server terminal. Lets call these two pipes, np1 and np2, where np1 is the connection from the client to the server.

        In the program running on the server terminal, the pipe np1 is opened in the read only mode.

...read more.

Middle

{

    int ReadFromPipe, WriteToPipe, return_val, NumChar;

    char buffer[MAX_BUF_SIZE];

               // Create the first named pipe

    return_val = mkfifo(NP1, 0666);

    if ( return_val == -1 && errno != EEXIST)

    {

        perror("Error creating the named pipe");

        exit(1);

    }

        //creates second named pipe

    return_val = mkfifo(NP2, 0666);

    if (return_val == -1 && errno != EEXIST)

    {

        perror("Error creating the named pipe");

        exit(1);

    }

            /* Open the first named pipe for reading */

        /* Open the second named pipe for writing */

    ReadFromPipe = open(NP1, O_RDONLY);

    WriteToPipe = open(NP2, O_WRONLY);

    while(1)

   {

                   /* Read from the first pipe */

        NumChar = read(ReadFromPipe, buffer, MAX_BUF_SIZE);

...read more.

Conclusion

//Reference: http://developers.sun.com/solaris/articles/named_pipes.html

#include <stdio.h>

#include <errno.h>

#include <ctype.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include "fullduplex.h" /* For name of the named-pipe */

int main()

{

    int WriteToPipe, ReadFromPipe, NumChar;

    char rdbuffer[MAX_BUF_SIZE];

        /* Open the first named pipe for writing*/

        /* Open the second named pipe for reading */

    WriteToPipe = open(NP1, O_WRONLY);

    ReadFromPipe = open(NP2, O_RDONLY);

    printf("Start conversation. Say something: ");    

   while(1)

   {

        gets(rdbuffer);

                /* Write to the pipe */

        write(WriteToPipe, rdbuffer, strlen(rdbuffer));

              /* Reads from the second pipe */

        NumChar = read(ReadFromPipe, rdbuffer, MAX_BUF_SIZE);

        rdbuffer[NumChar] = 0;        //ends the string by placing '0' in the next slot

        printf("Server says: %s\nYou say: ", rdbuffer);

   }

}

SCREENSHOTS

image00.png

...read more.

This student written piece of work is one of many that can be found in our University Degree Software Engineering section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related University Degree Software Engineering essays

  1. software program specification and code for a DVD store

    House of wax.\n"; cout <<"================" <<endl; cout <<"Starring: Elisha Cuthbert, Chad Michael Murray.\n"; cout <<"Director: Jaume Serra.\n"; cout <<"Genre: Horror.\n"; cout <<"Format: Widescreen.\n"; cout <<"Language: English.\n"; cout <<"Subtitles: English.\n"; cout <<endl<<endl; // displays 2 blank lines break; case 4: cout <<"1.

  2. Programming Concepts. Andora Video is a small shop selling videos. The owner, Raul, wishes ...

    set 4 �9.99 0/% 17.5% �46.95 �46.953 pass 2 Cloverfield 8 �13.99 12% 17.5% �115.72 �115.72528 pass 3 Be Kind Rewind 13 �10.50 17% 17.5% �133.12 �133.121625 pass 4 The Lord of the Rings - 3 vol set 24 �30.00 25% 17.5% �634.50 �634.5 pass As can be seen, there were no logical errors in this version.

  1. MS Office solutions. Fantasy mobiles require: ...

    A if statement is used to determine which calculation should be made depending upon the radio button selected. The end calculation is displayed in the 'Answer' label. 2.7 Functional Testing Test No. Test Details Expected Result Actual Result 7.

  2. 3ISE517 Internet Application Programming - CGI

    Upon submission, the file specified in the action attribute of the form would be requested from the server. This form would request a CGI script on submission. The information that the user has entered in the form can be submitted by 2 methods: GET and POST.

  1. Complete Section 2 of 3

    Sybase ASE Express Edition for Linux is the first enterprise-class commercial database that can take you from pilot to deployment for zero dollars and zero risk. As an enterprise-class data management platform, you can manage growth and evolving requirements without painful, expensive upgrades. I would consider SQL for administrative purposes.

  2. Complete Section 3 of 3

    The individuals who will receive the training are first identified, based on the criteria described in the training plan. Each individual is then contacted to explain the purpose of the training and to determine the most convenient schedule for their attendance.

  1. to help in the selection of tools that support the software quality management process.

    estimate, processes, documentation, and so on), and these tools can help in some of the tasks and activities of the software development process. Currently, few software development organizations have tools to support quality management, mainly due to lack of information about their availability.

  2. Abstract This report is dedicated to demonstrating and critically reviewing new features and developments ...

    dependent on each other, one of them will fail if the other one doesn't finish on time. Although the kernel for Windows 7 will remain almost the same as for Windows Vista, Windows 7 is enhanced with several tweaks so that it can take advantage of the newer multi-core CPUs.

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work