0% found this document useful (0 votes)
197 views3 pages

RPC Client Server For Movie Ticket Booking

The document describes an RPC client-server program for movie ticket booking. It includes: 1) Defining an IDL interface with procedures for booking, cancelling, and checking availability. 2) Creating a server that implements the interface functions and stores ticket counts in an array. 3) Creating a client that calls the interface functions, passing arguments and printing results. 4) The client allows the user to book, cancel tickets, or check availability by calling the corresponding server functions.

Uploaded by

saranya n r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
197 views3 pages

RPC Client Server For Movie Ticket Booking

The document describes an RPC client-server program for movie ticket booking. It includes: 1) Defining an IDL interface with procedures for booking, cancelling, and checking availability. 2) Creating a server that implements the interface functions and stores ticket counts in an array. 3) Creating a client that calls the interface functions, passing arguments and printing results. 4) The client allows the user to book, cancel tickets, or check availability by calling the corresponding server functions.

Uploaded by

saranya n r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Ex.

No:6 RPC CLIENT-SERVER FOR MOVIE TICKET BOOKING

25-01-17

AIM:

To write a rpc client server program for an application(movie ticket booking)

ALGORITHM:

1 Create the IDL with a .x extension


2 Declare the procedures and the versions with separate functions for ticket booking,
ticket cancellation and check availability
3 Create the client and server code and makefile using rpcgen
4 Declare the functions in the server
5 Call the respective functions from the client based on input from the user
6 The result will be displayed by the server and returned to the client

PROGRAM:

SERVER:

#include "add.h"

int ids[]={50,40,80};

int *book_1_svc(numbers *argp, struct svc_req *rqstp)

{ static int result;

ids[argp->id]=ids[argp->id]-argp->num;

result=ids[argp->id]; return &result; }

int * cancel_1_svc(numbers *argp, struct svc_req *rqstp)

{ static int result; ids[argp->id]=ids[argp->id]+argp->num;

result=ids[argp->id]; return &result; }

int * view_1_svc(numbers *argp, struct svc_req *rqstp)

{ static int result;

result=ids[argp->id]; return &result; }

CLIENT:

#include "add.h"

Void addition_1(char *host,int ch,int num,int id)

{ CLIENT *clnt; int *result_1;


numbers book_1_arg,cancel_1_arg,view_1_arg;

#ifndef DEBUG

if(ch==1){ book_1_arg.id=id;

book_1_arg.num=num;

clnt = clnt_create (host, ADDITION, ADDITION_1, "udp");

if (clnt == NULL) {clnt_pcreateerror (host); exit (1); }

result_1 = book_1(&book_1_arg, clnt);

if (result_1 == (int *) NULL) {clnt_perror (clnt, "call failed");}

printf("TICKET BOOKED SUCCESSFULLY\n");

printf("Available seats for screen %d is: %d",id,*result_1);}

else if(ch==2){ cancel_1_arg.id=id; cancel_1_arg.num=num;

clnt = clnt_create (host, ADDITION1, ADDITION_11, "udp");

if (clnt == NULL) {clnt_pcreateerror (host);

exit (1); } #endif /* DEBUG */

result_1 = cancel_1(&cancel_1_arg, clnt);

if (result_1 == (int *) NULL) {clnt_perror (clnt, "call failed");}

printf("TICKET CANCELLED SUCCESSFULLY");

printf("Remaining seats available for screen %d is %d",id,*result_1);}

else if(ch==3){view_1_arg.id=id; view_1_arg.num=num;

clnt = clnt_create (host, ADDITION2, ADDITION_12, "udp");

if (clnt == NULL) {clnt_pcreateerror (host); exit (1);}

result_1 = view_1(&view_1_arg, clnt);

if (result_1 == (int *) NULL) {clnt_perror (clnt, "call failed"); }

printf("SEATS AVAILABLE FOR SCREEN %d is : %d",id,*result_1);}

#ifndef DEBUG clnt_destroy (clnt); #endif /* DEBUG */ }

Int main (int argc, char *argv[])

{ char *host; int ch,num,id;


if (argc < 2) { printf ("usage: %s server_host\n", argv[0]);

exit (1);}host = argv[1];

printf("\t******MOVIE TICKET BOOKING******\n");

printf("\tSCREEN NAMES ARE 0,1,2\n");

printf("ENTER YOUR CHOICE 1.BOOK 2.CANCEL 3.VIEW\n");

scanf("%d",&ch);

if(ch==1||ch==2){ printf("ENTER THE NO.OF SEATS AND SCREEN NUMBER");

scanf("%d%d",&num,&id);}

else if(ch==3){ printf("ENTER THE SCREEN NUMBER TO CHECK AVAILABILITY");

scanf("%d",&id); num=0;}

addition_1 (host,ch,num,id); exit (0); }

OUTPUT:

RESULT:

Thus the rpc program for movie ticket booking was successfully completed and
executed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy