Skip to content

Commit 76e49ff

Browse files
author
Anchor
committed
Fix typos and grammar
1 parent 9a0dc6c commit 76e49ff

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

en/eBook/08.4.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
# 8.4 RPC
22

3-
In previous sections we talked about how to write network applications based on Sockets and HTTP, we learned that both of them are using "information exchange" model, which clients send requests and servers response. This kind of data exchange are based on certain format so both sides are able to understand. However, many independence applications do not use this model, but call services just like call normal functions.
3+
In previous sections we talked about how to write network applications based on Sockets and HTTP. We learned that both of them use the "information exchange" model, in which clients send requests and servers respond to them. This kind of data exchange is based on a specific format so that both sides are able to communicate with one another. However, many independent applications do not use this model, but instead call services just like they would call normal functions.
44

5-
RPC was intended to achieve the function call mode networking. Clients like calling native functions, and then packaged these parameters after passing through the network to the server, the server unpacked process execution, and executes the results back to the client.
5+
RPC was intended to be the function call mode for networked systems. Clients execute RPCs like they call native functions, except they package the function parameters and send them through the network to the server. The server can then unpack these parameters and process the request, executing the results back to the client.
66

7-
In computer science, a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote. When the software in question uses object-oriented principles, RPC is called remote invocation or remote method invocation.
7+
In computer science, a remote procedure call (RPC) is a type of inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote. When the software in question uses object-oriented principles, RPC is called remote invocation or remote method invocation.
88

99
## RPC working principle
1010

1111
![](images/8.4.rpc.png?raw=true)
1212

13-
Figure 8.8 RPC working principle.
13+
Figure 8.8 RPC working principle
1414

15-
Normally, a RPC call from the client to the server has following ten steps:
15+
Normally, an RPC call from client to server has the following ten steps:
1616

1717
- 1. Call the client handle, execute transfer arguments.
1818
- 2. Call local system kernel to send network messages.
1919
- 3. Send messages to remote hosts.
2020
- 4. The server receives handle and arguments.
2121
- 5. Execute remote processes.
22-
- 6. Return execute result to corresponding handle.
22+
- 6. Return execution result to corresponding handle.
2323
- 7. The server handle calls remote system kernel.
2424
- 8. Messages sent back to local system kernel.
2525
- 9. The client handle receives messages from system kernel.
2626
- 10. The client gets results from corresponding handle.
2727

2828
## Go RPC
2929

30-
Go has official support for RPC in standard library with three levels which are TCP, HTTP and JSON RPC. Note that Go RPC is not like other traditional RPC systems, it requires you to use Go applications on both sides of clients and servers because it encodes content through Gob.
30+
Go has official support for RPC in its standard library on three levels, which are TCP, HTTP and JSON RPC. Note that Go RPC is not like other traditional RPC systems. It requires you to use Go applications on both client and server sides because it encodes content using Gob.
3131

32-
Functions of Go RPC have to follow following rules for remote access, otherwise corresponding calls will be ignored.
32+
Functions of Go RPC have must abide by the following rules for remote access, otherwise the corresponding calls will be ignored.
3333

34-
- Functions are exported(capitalize).
34+
- Functions are exported (capitalize).
3535
- Functions have to have two arguments with exported types.
36-
- The first argument is for receiving from the client, and the second one has to be pointer type and is for replying to the client.
36+
- The first argument is for receiving from the client, and the second one has to be a pointer and is for replying to the client.
3737
- Functions have to have a return value of error type.
3838

3939
For example:
4040

4141
func (t *T) MethodName(argType T1, replyType *T2) error
4242

43-
Where T, T1 and T2 must be able to encoded by package `encoding/gob`.
43+
Where T, T1 and T2 must be able to be encoded by the `package/gob` package.
4444

45-
Any kind of RPC have to through network to transfer data, Go RPC can either use HTTP or TCP, the benefits of using HTTP is that you can reuse some function in package `net/http`.
45+
Any kind of RPC has to go through a network to transfer data. Go RPC can either use HTTP or TCP. The benefits of using HTTP is that you can reuse some functions from the `net/http` package.
4646

4747
### HTTP RPC
4848

@@ -144,17 +144,17 @@ Client side code:
144144

145145
}
146146

147-
We compile the client and the server side code separately, start server and start client, then you'll have something similar as follows after you input some data.
147+
We compile the client and the server side code separately then start the server and client. You'll then have something similar as follows after you input some data.
148148

149149
$ ./http_c localhost
150150
Arith: 17*8=136
151151
Arith: 17/8=2 remainder 1
152152

153-
As you can see, we defined a struct for return type, we use it as type of function argument in server side, and use as type of the second and third arguments in the client `client.Call`. This call is very important, it has three arguments, where the first one the name of function that is going to be called, and the second is the argument you want to pass, the last one is the return value(pointer type). So far we see that it's easy to implement RPC in Go.
153+
As you can see, we defined a struct for the return type. We use it as type of function argument on the server side, and as the type of the second and third arguments on the client `client.Call`. This call is very important. It has three arguments, where the first one is the name of the function that is going to be called, the second is the argument you want to pass, and the last one is the return value (of pointer type). So far we see that it's easy to implement RPC in Go.
154154

155155
### TCP RPC
156156

157-
Let's try the RPC that is based on TCP, here is the serer side code:
157+
Let's try the RPC that is based on TCP, here is the server side code:
158158

159159
package main
160160

@@ -218,9 +218,9 @@ Let's try the RPC that is based on TCP, here is the serer side code:
218218
}
219219
}
220220

221-
The different between HTTP RPC and TCP RPC is that we have to control connections by ourselves if we use TCP RPC, then pass connections to RPC for processing.
221+
The difference between HTTP RPC and TCP RPC is that we have to control connections by ourselves if we use TCP RPC, then pass connections to RPC for processing.
222222

223-
As you may guess, this is a blocking pattern application, you are free to use goroutine to extend this application for more advanced experiment.
223+
As you may have guessed, this is a blocking pattern. You are free to use goroutines to extend this application as a more advanced experiment.
224224

225225
The client side code:
226226

@@ -270,11 +270,11 @@ The client side code:
270270

271271
}
272272

273-
The only difference in client side code is that HTTP client uses DialHTTP where TCP client uses Dial(TCP).
273+
The only difference in the client side code is that HTTP clients use DialHTTP whereas TCP clients use Dial(TCP).
274274

275275
### JSON RPC
276276

277-
JSON RPC encodes data to JSON instead of gob, let's see an example of Go JSON RPC server side code sample:
277+
JSON RPC encodes data to JSON instead of gob. Let's see an example of a Go JSON RPC on the server:
278278

279279
package main
280280

@@ -339,7 +339,7 @@ JSON RPC encodes data to JSON instead of gob, let's see an example of Go JSON RP
339339
}
340340
}
341341

342-
JSON RPC is based on TCP, it hasn't support HTTP yet.
342+
JSON RPC is based on TCP and doesn't support HTTP yet.
343343

344344
The client side code:
345345

@@ -391,7 +391,7 @@ The client side code:
391391

392392
## Summary
393393

394-
Go has good support of HTTP, TPC, JSON RPC implementation, we can easily develop distributed web applications; however, it is regrettable that Go hasn't support for SOAP RPC which some third-party packages did it on open source.
394+
Go has good support for HTTP, TPC and JSON RPC implementation which allow us to easily develop distributed web applications; however, it is regrettable that Go doesn't have built-in support for SOAP RPC, although some open source third-party packages do offer this.
395395

396396
## Links
397397

0 commit comments

Comments
 (0)