Class Server
gRPC server. A single server can serve an arbitrary number of services and can listen on more than one port.
Inheritance
Inherited Members
Namespace: Grpc.Core
Assembly: Grpc.Core.dll
Syntax
public class Server
Constructors
Server()
Creates a new server.
Declaration
public Server()
Server(IEnumerable<ChannelOption>)
Creates a new server.
Declaration
public Server(IEnumerable<ChannelOption> options)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ChannelOption> | options | Channel options. |
Properties
Ports
Ports on which the server will listen once started. Register a port with this server by adding its definition to this collection.
Declaration
public Server.ServerPortCollection Ports { get; }
Property Value
Type | Description |
---|---|
Server.ServerPortCollection |
RequestCallTokensPerCompletionQueue
Experimental API. Might anytime change without prior notice. Number or calls requested via grpc_server_request_call at any given time for each completion queue.
Declaration
public int RequestCallTokensPerCompletionQueue { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Services
Services that will be exported by the server once started. Register a service with this server by adding its definition to this collection.
Declaration
public Server.ServiceDefinitionCollection Services { get; }
Property Value
Type | Description |
---|---|
Server.ServiceDefinitionCollection |
ShutdownTask
To allow awaiting termination of the server.
Declaration
public Task ShutdownTask { get; }
Property Value
Type | Description |
---|---|
System.Threading.Tasks.Task |
Methods
KillAsync()
Requests server shutdown while cancelling all the in-progress calls. The returned task finishes when shutdown procedure is complete.
Declaration
public Task KillAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Remarks
It is strongly recommended to shutdown all previously created servers before exiting from the process.
ShutdownAsync()
Requests server shutdown and when there are no more calls being serviced, cleans up used resources. The returned task finishes when shutdown procedure is complete.
Declaration
public Task ShutdownAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Remarks
It is strongly recommended to shutdown all previously created servers before exiting from the process.
Start()
Starts the server.
Throws IOException
if not all ports have been bound successfully (see Ports.Add
method).
Even if some of that ports haven't been bound, the server will still serve normally on all ports that have been
bound successfully (and the user is expected to shutdown the server by invoking ShutdownAsync
or KillAsync
).
Declaration
public void Start()