dev/c/ServerNBTHR/ServerSideProc.c

32 lines
778 B
C
Raw Normal View History

/*
2011-05-02 12:11:12 +04:00
ServerSideProc.c
*/
#include "square.h"
#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 12:11:12 +04:00
bool_t squareproc_2_svc(square_in * inp, square_out * outp, struct svc_req *rqstp)
{
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;
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 12:11:12 +04:00
int square_prog_2_freeresult(SVCXPRT * transp, xdrproc_t xdr_result, caddr_t result)
{
2011-05-02 12:11:12 +04:00
xdr_free(xdr_result, result);
return (1);
}