This project is a simple demonstration of Remote Procedure Call (RPC) in Go, implementing a basic client-server model. The server listens on port 3000 and provides a service to greet the user. The client sends a request with a argument to the server's method.
- Programming Language: Go
- Networking: TCP for communication between client and server
Before running this project, ensure you have the following installed:
- Go (Golang) 1.19 or later
- Git
- A text editor such as Visual Studio Code (optional).
Use the following command to clone the project from GitHub:
git clone https://github.com/ciizao/RPC_Go.git
Move into the project directory where the server and client files are located.The server file is named server.go. Start the server by running the following command:
cd RPC_Go
go run server.go
The client code is located in the client folder. Navigate to it and execute the client:
cd client
go run client.go
-
- The client will send a request to the server and display the server's response
When the server is running, it will log the following upon receiving a request:
Server RPC listening on port 3000...
When the client runs successfully, it will print:
Hello World + with RPC and Go
-
Server:
- Listens on TCP port
3000. - Provides an RPC service (
HelloService) with the methodSayHello, which takes aNameargument and returns a personalized greeting.
- Listens on TCP port
-
Client:
- Connects to the server at
localhost:3000. - Sends a request with a
Nameargument to the server'sSayHellomethod. - Receives and prints the server's response.
- Connects to the server at
-
RPC Concept:
- Demonstrates Remote Procedure Call (RPC) where the client can call methods on the server as if they were local functions.
- The source code for this project is available on GitHub:
https://github.com/ciizao/RPC_Go.git
