• 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. 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.

  2. 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.

  1. 3ISE517 Internet Application Programming - CGI

    Email address without the '@' sign 10. No option selected But as the same error message come for each test, the screenshots for certain validations are shown below. Test 1: Two names written Test 2 - 4: Invalid Input for the Name Test 5 - 7: Invalid Input for the Age Test 8-9: Invalid Input for the

  2. software program specification and code for a DVD store

    sets the number of decimal places to two { cout << "\nOrder calculation." << endl<<endl; aed aa// display 2 blank lines cout << "\nPlease enter cost of DVD: "; cin >> DVDcost; } { cout << "\nPlease enter number of copies required: "; cin >> number; } if (number<4)

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

    The DESMET evaluation method separates evaluation exercises into two main types: quantitative evaluations aimed at establishing measurable effects of using a method or tool; and qualitative evaluations aimed at establishing method or tool appropriateness, that is, how well a method or tool fits the needs and culture of an organization.

  2. Creating a database system for Mr Azizur Rahman, Mr Bilal Sheikh and Mr Iman ...

    I will now explain step by step on how the current system works. First of all the members of N.E.T have organised a recording sheet on which customer details, user requirements and faults with current computer can all be recorded.

  1. Why is something needed? - We're about to reach the end of what might ...

    The point is that enthusiasm for computers has progressed to the point that our society is already completely committed to using them, and is becoming utterly dependent on them working correctly and continuously. But, commercial computer systems, as we currently build them, simply aren't worthy of our unreserved trust and confidence.

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

    [8] Following are several examples. Example 1, in Windows 7, the desktop uses a ?superbar? taskbar (see Figure 1.2).

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