2011-05-02 10:53:52 +04:00
|
|
|
|
/*
|
2011-05-02 12:11:12 +04:00
|
|
|
|
ServerSideProc.c
|
|
|
|
|
*/
|
|
|
|
|
#include "square.h"
|
2011-05-02 10:53:52 +04:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <rpc/pmap_clnt.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <memory.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
2011-05-02 12:11:12 +04:00
|
|
|
|
int request = 0;
|
2011-05-02 10:53:52 +04:00
|
|
|
|
|
2011-05-02 12:11:12 +04:00
|
|
|
|
bool_t squareproc_2_svc(square_in * inp, square_out * outp, struct svc_req *rqstp)
|
2011-05-02 10:53:52 +04:00
|
|
|
|
{
|
2011-05-02 12:23:17 +04:00
|
|
|
|
printf("Thread id = '%ld' started, arg = %ld\n", pthread_self(), inp->arg1);
|
2011-05-02 12:11:12 +04:00
|
|
|
|
/*
|
|
|
|
|
Имитация работы процедуры , выполняемой потоками сервера
|
|
|
|
|
*/
|
|
|
|
|
sleep(5);
|
|
|
|
|
outp->res1 = inp->arg1 * inp->arg1;
|
2011-05-02 12:23:17 +04:00
|
|
|
|
printf("Thread id = '%ld' is done %ld \n", pthread_self(), outp->res1);
|
2011-05-02 12:11:12 +04:00
|
|
|
|
return (TRUE);
|
2011-05-02 10:53:52 +04:00
|
|
|
|
}
|
2011-05-02 12:11:12 +04:00
|
|
|
|
|
|
|
|
|
int square_prog_2_freeresult(SVCXPRT * transp, xdrproc_t xdr_result, caddr_t result)
|
2011-05-02 10:53:52 +04:00
|
|
|
|
{
|
2011-05-02 12:11:12 +04:00
|
|
|
|
xdr_free(xdr_result, result);
|
|
|
|
|
return (1);
|
2011-05-02 10:53:52 +04:00
|
|
|
|
}
|