09 February, 2015

Updated Practical#2

Aim: Programs related to interposes communication using pipes.
(RHS) Theory: Program You know 
               a) Sender.c
               b) Receiver.c 
(LHS) Output:




//Sender.c File
#include"stdio.h"
#include"sys/stat.h"
#include"fcntl.h"
int main()
{
 char data[100];
 int fd=0, len=0, i=1;
 fd=open("Datapipe",O_WRONLY);
 if(fd==-1)
  {
   printf("\n Receiver process has not created yet");
   return 1;
  }
while(1)
{
 len=read(0,data,100);
 if(len<=1)
  {
    break;
  }
 write(fd,data,len);
}
close(fd);
printf("\n");
return 0;
}


On Next Page
// Receiver.c file
#include"stdio.h"
#include"sys/stat.h"
#include"fcntl.h"
int main()
{
 char data[100];
 int fd=0, len=0, i=1;
 unlink("Datapipe");
 mkfifo("Datapipe",0660);
 fd=open("Datapipe",O_RDONLY);
 if(fd==-1)
  {
   printf("\n Error creating pipe");
   return 1;
  }
while(1)
{
 len=read(fd,data,100);
 if(len<=0)
  {
    break;
  }
 data[len]='\0';
 printf("\nString %d : %s",1,data);
 i++;
}
close(fd);
unlink("Datapipe");
printf("\n");
return 0;
}



LHS:
AIM:………………………………

Compile:
Termianl 1:
 gcc sender.c –o sender.out
 gcc receiver.c –o receiver.out
Run:
Terminal 1:
./receiver.out
Terminal 2:
./sender.out
Now take screen shots after run the program in proper way


MCQ-I Review

Highest Marks: 16.75 out of 20.
Lowest Marks: 1.5 out of 20.

MCQ test on Networking Programming

 Answers are shows as Bold.
1.At a particular time the value of the counting semaphore is 15. It will 
            become 17 after ?
a. 3P and 2V   b) 4V only       c) 4P and 7V               d) 5V and 3P

2.At a particular time the value of the counting semaphore is 25. After 3P and 5V operation, what wil be the value for Semaphore?
      a)      25                    b) 28                c) 27                d). 26

3.Which of the following is true in the context of Inter-process communication:
 a). It is like a user defined procedure call.           b). It is like user defined a function call.
 c). It is a system call.                                           d). None of the above

4. Bounded capacity and Unbounded capacity queues are referred to as :
a) Programmed buffering                                b) Automatic buffering
c) User defined buffering                               d) No buffering

5) In the non blocking send
a) the sending process keeps sending until the message is received
b) the sending process sends the message and resumes operation
c) the sending process keeps sending until it receives a message
d) None of these

6) The link between two processes P and Q to send and receive messages is called :
a) communication link                      b) message-passing link
c) synchronization link                        d) All of these

7. Which layer is responsible for process to process delivery?
a) network layer          b) transport layer      c) session layer d) data link layer

8.Transmission data rate is decided by
a) network layer          b) physical layer        c) data link layer         d) transport layer

9. Which one of the following task is not done by data link layer?
a) framing        b) error control            c) flow control                        d) channel coding

10. RPC allows a computer program to cause a subroutine to execute in
a) its own address space b) another address space c) both (a) and (b) d) none of the mentioned

11. RPC is a
a) synchronous operation b) asynchronous operation          c) time independent operation d) none

12. The local operating system on the server machine passes the incoming packets to the
a) server stub b) client stub   c) client operating system       d) none of the mentioned

13. Remote procedure calls is
a) inter-process communication b) a single process c) a single thread d) none of the mentioned.

14……….refers to computing technologies in which the hardware and software components are distributed across a network.
a)Client and Server   b) User and System     c) User and file server  d) User and database server

15. Which of the following is not the correct benefit of distributed computing.
a) Resource sharing                 b) Performance            c) Availability d) Security

16. OSI stands for
D) Open System Interconnection


17 How many layers are in TCP/IP
 a) 7     b) 4      c) 5      d) 3

18.The OSI model start with which layer?
a) Physical Layer         b) Network Layer       c) Application Layer d) Presentation Layer

19.Packets are available in which layer?
a) Physical Layer         b) Network Layer     c) Application Layer   d) Presentation Layer

20. Data Compression is done at which layer?
a) Physical Layer         b) Network Layer       c) Application Layer   d) Presentation Layer