@ -291,9 +293,9 @@ implementation available from the network.
```
```
- it provides a class `GreetingsServer` that holds a `ServerImpl` that will run the server
The `GreetingsServer` class has a `ServerImpl` member that actually runs the server. To create an appropriate `ServerImpl`, we use a special `ServerBuilder` class (in this case a `NettyServerBuilder`) in the `GreetingsServer`'s `start` method, binding the `GreetingsService` implementation that we created to a port. Then we start the server running: the server is now ready to receive requests from `Greetings` service clients on our specified port. We'll cover how all this works in a bit more detail in our language-specific documentation.
- in the `start` method, `GreetingServer` binds the `GreetingsService` implementation to a port and begins running it
- there is also a `stop` method that takes care of shutting down the service and cleaning up when the program exits
`GreetingsServer` also has a `stop` method that takes care of shutting down the service and cleaning up when the program exits.
#### Build it
#### Build it
@ -308,16 +310,16 @@ We'll look at using a client to access the server in the next section.
<aname="client"></a>
<aname="client"></a>
### Writing a client
### Writing a client
Client-side gRPC is pretty simple. In this step, we'll use the generated code to write a simple client that can access the `Greetings` server we created in the previous section. You can see the complete client code in [GreetingsClient.java](src/main/java/ex/grpc/GreetingsClient.java).
Client-side gRPC is pretty simple. In this step, we'll use the generated code to write a simple client that can access the `Greetings` server we created in the [previous section](#server). You can see the complete client code in [GreetingsClient.java](java/src/main/java/ex/grpc/GreetingsClient.java).
Again, we're not going to go into much detail about how to implement a client - we'll leave that for the tutorial.
Again, we're not going to go into much detail about how to implement a client - we'll leave that for the tutorial.
#### Connecting to the service
#### Connecting to the service
. The internet address
First let's look at how we connect to the `Greetings` server. The internet address
is configured in the client constructor. gRPC Channel is the abstraction over
is configured in the client constructor. gRPC `Channel`provides the abstraction layer over
transport handling; its constructor accepts the host name and port of the
transport handling; its constructor accepts the host name and port of the
service. The channel in turn is used to construct the Stub.
service. The channel in turn is used to construct the stub instance.
```java
```java
@ -335,11 +337,11 @@ service. The channel in turn is used to construct the Stub.
#### Obtaining a greeting
#### Obtaining a greeting
The greet method uses the stub to contact the service and obtain a greeting.
The `greet()` method uses the stub to contact the service and obtain a greeting.
It:
In the method we:
- constructs a request
- construct and fill in a `HelloRequest` to send to the stub
- obtains a reply from the stub
- get a reply from the stub
- prints out the greeting
- print out the greeting
```java
```java
@ -375,7 +377,7 @@ line.
#### Build the client
#### Build the client
This is the same as before: our client and server are part of the same maven
This is the same as building the server: our client and server are part of the same maven
package so the same command builds both.
package so the same command builds both.
```
```
@ -407,6 +409,10 @@ and in another terminal window confirm that it receives a message.