Thursday, December 31, 2009

Good Online tutorials

Microsoft Sql Server 2008

SQL

Java
http://progzoo.net/wiki/ProgZoo(editor for java,c#,c++,perl,ruby,python,VB)

C#

Adobe Flex

MBasic

SOFTWARE ENGINEERING

Friday, November 27, 2009

Tuesday, November 17, 2009

MLA Citations


MLA citation generator:


http://citationmachine.net/index2.php?reqstyleid=1&mode=form&reqsrcid=MLAWeblog&more=yes&nameCnt=1 



Monday, August 31, 2009

Some definitions of Computer Networks

PACKET-SWITCHING: It typically use a strategy called store-and-forward. Each node first receives a complete packet over some link, stores the packet in its internal memory, and then forwards the complete packet to the next node.

CIRCUIT-SWITCHING: It establishes a dedicated circuit across a sequence of links and then allows the source node to send a stream of bits across this circuit to destination node.

CLOUD: Any type of network e.g. point-to-point, multiple access, switched.

SEMANTIC GAP: Gap between what the application expects and what the underlying technology can provide.

GENERAL CLASSES OF FAILURES THAT NETWORK DESIGNERS HAVE TO WORRY: First, Bit-level errors(Electrical interference). Second, Packet-level errors(congestion). Third is link and node failure. if the network overcomes the above three failure then the network can provide reliability.

TWO NICE FEATURES OF LAYERING: First, it decomposes the problem of building a network into more manageable components. You can implement several layers, each of which solves one part of the problem. Second, it provides a more modular design. If you decide that you want to add some new service, you may only need to modify the functionality at one layer, reusing the function provided at all the other layers.

PROTOCOL: The abstract objects that make up the layers of a network system are called protocols. Each protocol defines two different interfaces, service interface and peer interface.

SERVICE INTERFACE: It defines the operations that local objects can perform on the protocol.

PEER INTERFACE: It defines the form and meaning of messages exchanged between protocol peers to implement the communication service.

OSI LAYERS:

Physical layer handles the transmission of raw bits over a communication link.

Data link layer then collects a stream of bits into a larger aggregate called a frame.

Network layer handles routing among nodes within a packet-switched network. At this layer unit of data exchanges among nodes is typically called packets.

Transport layer then implement process-to-process communication channel. At this layer unit of data exchanged is commonly called a message.

Session layer provides a name space for connection management, that is used to tie together the potentially different transport streams that are part of the single application.

Presentation layer is concerned with the format of data exchanged between peers.

Application layer is concerned with the different applications can interoperate with below layer.

DEMUX KEY (OR) DEMULTIPLEXING KEY: Protocol attaches a header to its message contains an identifier that records the application to which the message belongs. we call this identifier demux key.

INTERNETWORK OR INTERNET: A set of independent networks are interconnected to form an internetwork.

BANDWIDTH: Number of bits that pushed on to the network per second.

LATENCY: Is amount of time taken to travel from source node to the destination node.

Address: A byte string that identifies a node.

SWITCH: It main function is to store and foward packets.

ROUTER OR GATEWAY: A node that is connected to two or more networks is commonly called a router or gateway. it also store and forwards messages like switch does, but between the different networks.

ROUTING: The process of determining systematically how to forward message toward the destination node based on its address is called routing.

UNICAST: A source node wants to send a message to single destination node is called unicast.

BROADCAST: A source node want to send a message to all the nodes on the network is called broadcast.

MULTICAST: A source node want to send a message to some subset of the other node, but not all of them, is called multicast.

MULTIPLEXING: It enable two are more transmission sources to share same media.

INTERLEAVING: The process of taking a group of bits from each input line for multiplexing is called interleaving.

FREQUENCY DIVISION MULTIPLEXING: Assignment of non-overlapping frequency ranges to each “user” or signal on a medium. Thus, all signals are transmitted at the same time, each using different frequencies.

A multiplexor accepts inputs and assigns frequencies to each device.

The multiplexor is attached to a high-speed communications line.

A corresponding multiplexor, or demultiplexor, is on the end of the high-speed line and separates the multiplexed signals.

SYNCHRONOUS-TIME DIVISION MULTIPLEXING: The multiplexor accepts input from attached devices in a round-robin fashion and transmit the data in a never ending pattern.

If one device generates data at a faster rate than other devices, then the multiplexor must either sample the incoming data stream from that device more often than it samples the other devices, or buffer the faster incoming stream.

If a device has nothing to transmit, the multiplexor must still insert a piece of data from that device into the multiplexed stream.

STATISTICAL MULTIPLEXING: A statistical multiplexor transmits only the data from active workstations

If a workstation is not active, no space is wasted on the multiplexed stream.

A statistical multiplexor accepts the incoming data streams and creates a frame containing only the data to be transmitted.

To identify each piece of data, an address is included.

If the data is of variable size, a length is also included.

Creating blocks and grids in CUDA

GPU's are capable of performing task that are performed by CPU's, CUDA was developed.

This program demonstrates how to create grids and block in a process.

#include stdio.h
#include cuda.h

// Kernel that executes on the CUDA device
__global__ void square_array()
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
printf("idx %d blockIdx.x %d blockDim.x %d threadIdx.x %d\n",idx,blockIdx.x,blockDim.x,threadIdx.x);
}

// main routine that executes on the host
int main(void)
{
int N=9; // length of an array
int block_size = 4; // number of threads that fit in a block
int n_blocks = N/block_size + (N%block_size == 0 ? 0:1); // number of blocks
square_array <<<>>> ();
}


if you execute the program you will get the following output:
xxxxx@hpcc:~/prog$ ./test
idx 0 blockIdx.x 0 blockDim.x 4 threadIdx.x 0
idx 1 blockIdx.x 0 blockDim.x 4 threadIdx.x 1
idx 2 blockIdx.x 0 blockDim.x 4 threadIdx.x 2
idx 3 blockIdx.x 0 blockDim.x 4 threadIdx.x 3
idx 4 blockIdx.x 1 blockDim.x 4 threadIdx.x 0
idx 5 blockIdx.x 1 blockDim.x 4 threadIdx.x 1
idx 6 blockIdx.x 1 blockDim.x 4 threadIdx.x 2
idx 7 blockIdx.x 1 blockDim.x 4 threadIdx.x 3
idx 8 blockIdx.x 2 blockDim.x 4 threadIdx.x 0
idx 9 blockIdx.x 2 blockDim.x 4 threadIdx.x 1
idx 10 blockIdx.x 2 blockDim.x 4 threadIdx.x 2
idx 11 blockIdx.x 2 blockDim.x 4 threadIdx.x 3

int block_size = 4;(it is blockDim.x, each block contain 4 threads)

int n_blocks = N/block_size + (N%block_size == 0 ? 0:1);
this instruction will generate n_blocks=3 (number of blocks, in above output it is blockIdx.x)

How to compile:

Write program and save it with ".cu" extension.
$xyz.cu

setup environment variables
$set up LD_LIBRARY_PATH
$export LD_LIBRARY_PATH=$PATH:/home/cuda/lib/

compile
$/home/cuda/bin/nvcc -deviceemu xyz.cu -o xyz

run
$./xyz

Monday, July 27, 2009

Batchers Bitonic sort

The example i am showing will only works for 2^n numbers.

First,we need to break up the given sequence into smaller parts,we call them individual sorting parts( initially two numbers in a part, for every step it will doubles). Now sort first part in increasing and the second in decreasing order and continue like this to the end.

Second, after sorting, if the sorted part having more than two number, then you need to sort numbers with-in, and ascending or descending order depends on which part it is.

example for 8 numbers:



example for 4 numbers:

Friday, July 17, 2009

Basic pthread programming

Here i demonstated a thread based programme. It counts number of 3's in an array of size 100000. we fill the array with random values. We need to give the number of thread, so that each thread shares part of the array and starts computation.

In this program i used some of the basic pthread commands.

int pthread_create( pthread_t *thread,const pthread_attr_t *attr, void* (*start_routine)(void*),void *arg);
This command creates a thread on a start_routine, arg is an argutment to the start_routine.Mostly we do not use attr, instead we put null.

int pthread_join(pthread_t thread, void **status);
This command is usefull when we are waiting for return value. Here return value is status.

int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
Above two commands are used for locking and unlocking


#include stdio.h,stdlib.h,pthread.h,sys/time.h
#define N 100000
int a[N],nt;
int part,tid;
pthread_mutex_t arg,args[N];

void * function(void *i)
{
int j,k,l,ltid,count,*ret;
pthread_t thread;
j=(int)i;
ltid=tid;
pthread_mutex_unlock(&arg);
k=j+part;

if(ltid==(nt-1))
k=N;
count=0;
for(l=j;l is less than k;l++)
{
if(a[l]==3)
{
count++;
}

}
printf("thread %d %d\n",ltid,count);
ret=count;
return((void *)ret);
}

main(int argc,char *argv[])
{
int i,rc,t;
int count=0,total=0;
pthread_t threads[N];
void *status;
srand (time(NULL));
struct timeval tim;
nt=atoi(argv[1]);

// filling array with random number between 0 to 9
for(i=0;i is less than N;i++)
{
a[i]=rand()%10;
}


part=N/nt;
t=0;
gettimeofday(&tim, NULL);
double t1=tim.tv_sec+(tim.tv_usec/1000000.0);

// creating threads
for(i=0;i is less than nt;i++)
{
pthread_mutex_lock(&arg);
rc=pthread_create(&threads[i],NULL,function,(void *)t);
if(rc)
{
printf("error while creating thread\n");
exit(1);
}
t+=part;
tid=i;
}

// Waiting for all threads
for(i=0;i is less than nt;i++)
{
status=0;
rc=pthread_join(threads[i],(void **)&status);
if(rc)
{
printf("error while joining thread\n");
exit(1);
}
total+=status;
}

gettimeofday(&tim, NULL);
double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
printf("3 repeated %d times in %4.3lf using threads\n",total,t2-t1);

}


Thursday, July 9, 2009

Wednesday, June 24, 2009

Basic programming of A4WD1 rover

Most of the lynxmotions robots uses the software provided by Basic Micro Technologies.

I will give the explanation of this Basic programming.

Basic programming supported by this rover is not exactly same as traditional one. It does not support all the commands and data structure.

// This program is not written by me, author is James Frye
// you will get source file at lynxmotion
'Program name: 4WD1AUTO.BAS 
'Author: My Friend Bharadwaj Srirangam   
'Connections 
'Pin 16 Jumper to battery (VS) 
'Pin 17 Left GP2D12 Sensor (Right facing sensor) 
'Pin 18 Right GP2D12 Sensor (Left facing sensor) 
'Pin 19 Rear GP2D12 Sensor 
'Pin 0 Left Sabertooth channel. 
'Pin 1 Right Sabertooth channel. 
'Pin 12 A Button. 
'Pin 13 B Button. 
'Pin 14 C Button. 
'Pin 9 Speaker.
; Datatype declaration temp  
var byte filter  
var word(10) 
ir_right var word 
ir_left  var word 
ir_rear  var word  
LSpeed  var word 
RSpeed  var word  
minspeed con 1750 
maxspeed con 1250  
LSpeed = 1500 
RSpeed = 1500  
low p0 
low p1  
sound 9, [100\880, 100\988, 100\1046, 100\1175]
; starting main 
main 
gosub sensor_check ;gosub is like function call  
; Numbers lower than 1500 result in forward direction. 
; Numbers higher than 1500 result in reverse direction. 
; min command below select the maximum expression.
; max command below evaluate the minimum expression.
LSpeed = (LSpeed - 10) min maxspeed ;accelerates the motors 
RSpeed = (RSpeed - 10) min maxspeed  
LSpeed = (LSpeed + ir_left) max minspeed ;when something is detected, this decelerates the opposite side 
RSpeed = (RSpeed + ir_right) max minspeed  
if (ir_rear > 15) then 
LSpeed = (LSpeed - ir_rear) min maxspeed ;if something is detected behind the robot, accelerates both sides 
RSpeed = (RSpeed - ir_rear) min maxspeed 
endif  ; 
Send out the servo pulses   
pulsout 0,(LSpeed*2) ; Left Sabertooth channel.  
pulsout 1,(RSpeed*2) ; Right Sabertooth channel.  
pause 20  
goto main   
sensor_check  
for temp = 0 to 9   
adin 17, filter(temp) 
next 
ir_right = 0 
for temp = 0 to 9   
ir_right = ir_right + filter(temp) 
next 
ir_right = ir_right / 85  
for temp = 0 to 9   
adin 18, filter(temp) 
next 
ir_left = 0 
for temp = 0 to 9   
ir_left = ir_left + filter(temp) 
next 
ir_left = ir_left / 85  
for temp = 0 to 9   
adin 19, filter(temp) 
next 
ir_rear = 0 
for temp = 0 to 9   
ir_rear = ir_rear + filter(temp) 
next 
ir_rear = ir_rear / 85  
; serout is like printf statement in c. we need to check this output at terminal 1 at 38.4kbps.  
serout s_out,i38400,["ir_right - ", dec ir_right, " ir_left - ", dec ir_left, " ir_rear - ", dec ir_rear, "LSpeed - ", dec LSpeed, " RSpeed - ", dec RSpeed, 13]  
return


Wednesday, June 10, 2009

Big endian vs Little endian


8 bits is a byte.
4 bytes is a word.




Above figure shows a 32 bit processor register.

Byte order: Byte3 Byte2 Byte1 Byte0

Little Endian: lower order byte of a number is stored in memory at lower address, and the higher order byte is stored at higher address.

Big Endian: lower order byte of a number is stored in memory at higer address, and the higher order byte is stored at lower address.

Example:

1001 / 2 = 1
500 / 2 = 0
250 / 2 = 0
125 / 2 = 1
62 / 2 = 0
31 / 2 = 1
15 / 2 = 1
7 / 2 = 1
3 / 2 = 1
1 / 2 = 1

= 1111101001(binary)


Thursday, May 28, 2009

Basic socket programming (TCP)

Sockets are end points on a machine for communication.

Below code demonstatres connection oriented program (TCP).

Client:
#include following libraries stdio.h, sys/socket.h, sys/types.h, netinet/in.h, netdb.h
int main(int argc,char **argv)
{
  int sockfd,newsockfd;  // socket descriptors 
  struct sockaddr_in serv_addr;
  struct hostent *he;
  char a[50],a1[50];
  sockfd=socket(AF_INET,SOCK_STREAM,0); // creates a socket
  if(sockfd<0)
  {
   printf("Socket failed");
   exit(0);
  }
// Use either green or yellow code, if you want to give server name as command line argument use the green one. 
  if((he=gethostbyname(argv[2]))==NULL)  // gets the ip address
  {
  printf("gethost error");
  exit(1);
  }
  serv_addr.sin_family=AF_INET;
  serv_addr.sin_addr.s_addr=inet_addr("127.127.127.1");
  memcpy(&(serv_addr.sin_addr),he->h_addr,he->h_length);
  serv_addr.sin_port=htons(atoi(argv[1])); 
  if(connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr))<0)
  {
   printf("\nConnection failed");
   exit(0);
  }
  printf("\nEnter a Message");
  scanf("%s",&a);
  write(sockfd,a,50);
  read(sockfd,a1,50);
  printf("\nClient received Message %s",a1);
  close(sockfd); // closing the socket descriptor
}


Server: 
#include following libraries stdio.h, sys/socket.h, sys/types.h, netinet/in.h
int main(int argc,char **argv)
{
  int sockfd,newsockfd,clilen;
  struct sockaddr_in serv_addr,cli_addr;
  char a[50];
  sockfd=socket(AF_INET,SOCK_STREAM,0);
  if(sockfd<0)
  {
   printf("\nSocket failed!");
   exit(0);
  }
  serv_addr.sin_family=AF_INET;
  serv_addr.sin_addr.s_addr=htonl(INADDR_ANY);
  serv_addr.sin_port=htons(atoi(argv[1]));
  if(bind(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr))<0)
  {
   printf("\nBind failed");
   exit(1);
  }
  if(listen(sockfd,5)<0)
  {
   printf("\nListen fails");
   exit(0);
  }
  clilen=sizeof(cli_addr);
  newsockfd=accept(sockfd,(struct sockaddr *)&cli_addr,&clilen);
  read(newsockfd,a,80);
  printf("Server received %s",a);
  write(newsockfd,"Server received message",26);
  close(newsockfd);
  close(sockfd);
}


compilation:
client :   gcc -o client client.c
server :   gcc -o server server.c

Execution:
server : ./server (portno)
client : ./client (portno) (servername)

Communication between client and server.


Client side:
client creates a socket and sends a request to server

Server side:
  1. Server creates a socket and waiting for a request.
  2. when request arrives to server socket then it creates a new socket and forward the request to that new socket. 
  3. Further communication is goes on in between client's socket and server's new socket.

Monday, May 11, 2009

Different ways of reading a file in C

In C there are different methods to read a file, but which is more suitable to your code is important. Here we look into different functions and see how it reads from a file.

file.txt (Input)
I am in your blogspot.

fscanf:

FILE *stream,*fopen();
stream=fopen("file.txt","r");
while(!feof(stream))
{
fscanf(stream,"%s",x);
printf("%s\n",x);
}

output:
I
am
in
your
blogspot.
blogspot.

It is clear that is taking string by string and printing on the screen. Have you notice blogspot. is printing twice. we can avoid that using memcpy command.

#include
main()
{
FILE *stream,*fopen();
char x[100];
stream=fopen("file.txt","r");
while(!feof(stream))
{
fscanf(stream,"%s",x);
printf("%s\n",x);
memcpy(x,"\0",100); // every time it clears x
}
}

Output:
I
am
in
your
blogspot.

fgets:

while(fgets(x,5, stream) != NULL)
{
printf("%s\n",x);
}

Output:
I am
 in
your
 blo
gspo
t.

Every time, fgets method takes 5 character from the stream and puts into user buffer.

fgetc:

x=fgetc(stream);
while(x!=EOF)
{
printf("%c\n",x);
x=fgetc(stream);
}

Output:
I

a
m

i
n

y
o
u
r

b
l
o
g
s
p
o
t
.

it reads character by character from file.

Friday, May 8, 2009

Shell script commands

It is similar to batch programming.

PRINT ON THE SCREEN

echo "Hello"

WRITE TO A FILE

echo "Hello" > file.txt

APPEND TO A FILE

echo "Hello" >> file.txt

TAKE INPUT FROM KEYBOARD

read d (some variable d)

EXAMPLE ON FOR LOOP

for d in 1 2 4 f g g d s
do
echo $d
done

EXAMPLE OF WHILE LOOP

n=1
i=1
while [ $i -le 10 ]
do
echo "$n * $i = `expr $i \* $n`"
i=`expr $i + 1`
done

Singleton

Singleton design patters are used where there is only one instance of an object is required.

Here is an example of singleton class.

public class singleton
{
private static singleton instance=null;
static public singleton getInstance()
{
if(instance==null)
instance=new singleton();
return instance;
}
private singleton()
{}
.
.
.
.
}

Saturday, May 2, 2009

Friday, March 27, 2009

Remote Method Invocation (RMI)

Following file are needed to put on Client
Conversion.java
ConversionClient.java
Data.java

On server:
Conversion.java
ConversionImpl.java
ConversionServer.java
Data.java

Conversion.java
public interface Conversion extends java.rmi.Remote
{
public Data conversion1(Data km) throws java.rmi.RemoteException;
public Data conversion2(Data km) throws java.rmi.RemoteException;
}


Data.java
import java.io.*;
public class Data implements Serializable {
    private static final long serialVersionUID = 1L;
    private float km;
    private int miles;
    private long foot;

    public Data() {
    }

    public float getKm() {
        return km;
    }

    public void setKm(float km) {
        this.km = km;
    }

    public int getMiles() {
        return miles;
    }

    public void setMiles(int miles) {
        this.miles =miles ;
    }

    public long getFoot() {
        return foot;
    }

    public void setFoot(long foot) {
        this.foot = foot;
    }
}

ConversionClient.java
import java.rmi.Naming; 
import java.rmi.RemoteException; 
import java.net.MalformedURLException; 
import java.rmi.NotBoundException; 
import java.io.*; 
import java.util.*;
import java.net.*;
public class ConversionClient
{
public static void main(String[] args) throws Exception
{
// Converting the hostname to ip address
InetAddress ia=InetAddress.getByName(args[0]);
// Looking up for the remote object in remote server
Conversion c=(Conversion) Naming.lookup("rmi://"+ia.getHostAddress()+":3000/ConversionServer");
// Enter kilometers
System.out.println("Enter Kilometers\n");
Scanner ob=new Scanner(System.in);
float km=ob.nextFloat();
System.out.println("val is "+km);
Data d=new Data();
d.setKm(km);
//passing values to two methods
int s=c.conversion1(d).getMiles();
long t=c.conversion2(d).getFoot();

// printing out the values 
System.out.println(km+"Kilometers ="+s+"Miles ");
System.out.println(km+"Kilometers ="+t+"Foot ");
}
}

ConversionImpl.java
import java.rmi.Naming; 
import java.rmi.RemoteException; 
import java.net.MalformedURLException; 
import java.rmi.NotBoundException; 

public class ConversionImpl extends java.rmi.server.UnicastRemoteObject implements Conversion
{
private static final long serialVersionUID = 1L;
public ConversionImpl() throws java.rmi.RemoteException
{
super();
}
// converts from Km to Miles
public synchronized Data conversion1(Data value) throws java.rmi.RemoteException
{
int r=(int)Math.round(value.getKm() * 0.62137119);
//System.out.println("r="+r);
value.setMiles(r);
return value;
}
// converts from Km to Foot
public synchronized Data conversion2(Data value) throws java.rmi.RemoteException
{
long r=(long)Math.round(value.getKm() * 3280.8399);
//System.out.println("r="+r);
value.setFoot(r);
return value;
}
}

ConversionServer.java
// This program is used to put the object referrence in rmiregistry
import java.rmi.*;
import java.net.*;
public class ConversionServer
{
public static void main(String args[])throws Exception
{
Conversion c=new ConversionImpl();
InetAddress ia=InetAddress.getLocalHost();
String h=ia.getHostName();
Naming.rebind("rmi://"+ia.getHostAddress()+":3000/ConversionServer",c); // putting the object referrence in rmi registry
}
}

To Compile:

1.a. Copy the folder "client" to the machine where you want to run client.
  b. Go to the folder "client" and run the command
     % javac *.java
2.a. Copy the folder "server" to the machine where you want to run the server.
  b. Go to the folder "server" and run the command
     % javac *.java

To Run the program:

1.On server machine
  a. Open a window to start rmiregistry
     % rmiregistry 3000
  b. Go to the folder "server" 
  c. Start the Server on another window
java ConversionServer 

2.a  Go to the folder "client" in client machine
  b. Start the client using the command
        java ConversionClient

Thursday, March 12, 2009

Friday, March 6, 2009

Remote Procedure Call

RPC (Remote Procedure Call), it is higher level programming to socket programming.

.x files are just like Interface in java. 

conversion.x  
struct conv{  
float x;
};
program conversion{ 
version conversion1_vers{
int conversion1(conv)=1;
}=1;
version conversion2_vers{
int converions2(conv)=1;
}=2;
}= 0x23451111; 

In Conversion.x, conv is a structures used to send a float value.
To generate client and server code use rpcgen
rpcgen -a -C conversion.x

along with client and server, it will also generate makefile.conversion and someother files.



conversion_client.c
/*
 * This is sample code generated by rpcgen.
 * These are only templates and you can use them
 * as a guideline for developing your own functions.
 */

#include "conversion.h"
#include
#include /* getenv, exit */


void
conversion_1(float a,char *host)
{
CLIENT *clnt;
int  *result_1;
conv  conversion1_1_arg;

#ifndef DEBUG
clnt = clnt_create(host, conversion, conversion1_vers, "netpath");
if (clnt == (CLIENT *) NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
conversion1_1_arg.x=a;
result_1 = conversion1_1(&conversion1_1_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror(clnt, "call failed");
}
        else
        {
        printf("%.2f Kilometers is equal to %d Miles\n",a,*result_1);
        }
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
}


void
conversion_2(float a,char *host)
{
CLIENT *clnt;
int  *result_1;
conv  converions2_2_arg;

#ifndef DEBUG
clnt = clnt_create(host, conversion, conversion2_vers, "netpath");
if (clnt == (CLIENT *) NULL) {
clnt_pcreateerror(host);
exit(1);
}
#endif /* DEBUG */
converions2_2_arg.x=a;
result_1 = converions2_2(&converions2_2_arg, clnt);
if (result_1 == (int *) NULL) {
clnt_perror(clnt, "call failed");
}
        else
        {
        printf("%.2f Kilometers is equal to %d Feet\n",a,*result_1);
        }
#ifndef DEBUG
clnt_destroy(clnt);
#endif /* DEBUG */
}


main(int argc, char *argv[])
{
char *host;
float a;
if (argc <>
printf("usage:  %s server_host\n", argv[0]);
exit(1);
}
host = argv[1];
//According to your logic you need to write your code, here i put "a" as a parameter in both conversion_1 and conversion_2 inorder to send to server.
        printf("Enter kilometers\n");
        scanf("%f",&a);
conversion_1(a,host);
conversion_2(a,host);
}

conversion_server.c
/*
 * This is sample code generated by rpcgen.
 * These are only templates and you can use them
 * as a guideline for developing your own functions.
 */

#include "conversion.h"
#include
#include /* getenv, exit */
#include
#include
int *
//After generating this code, we need to write our definition to this methods.
conversion1_1_svc(conv *argp, struct svc_req *rqstp)
{
static int  result;

/*
* insert server code here
*/
        result=(int)floorf((argp->x/1.61)+0.5);
        printf("1st resutl is %d\n",result);
return (&result);
}

int *
converions2_2_svc(conv *argp, struct svc_req *rqstp)
{
static int  result;

/*
* insert server code here
*/
result=(int)floorf(((argp->x) * 3280.839895)+0.5);
        printf("2nd result is %d\n",result);
return (&result);
}

Change the make.conversion to makefile.
mv makefile.conversion makefile

in makefile you need to change the following.
CC=gcc  // default is cc
CFLAGS += -g -DRPC_SVC_FG
RPCGENFLAGS = -C

To compile
$ make

Open two command prompts, one for server and other for client.
$./conversion_server

$./conversion_client