namespace Service
{
class Program
{
const int Port = 9007;
static void Main(string[] args)
{
Server server = new Server
{
Services = { HelloWorld.BindService(new HelloService()) },
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();
Console.WriteLine("RouteGuide server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
}
}
}
namespace Client
{
class Program
{
static void Main(string[] args)
{
Channel channel = new Channel("127.0.0.1:9007", ChannelCredentials.Insecure);
var client = new HelloWorld.HelloWorldClient(channel);
var retrunstr = client.SayHello(new HellowRequest() { Title = "this is message", Content = "this is content" });
//var retrunstr = await client.SayHelloAsync(new HellowRequest() { Title = "this is message", Content = "this is content" });
Console.WriteLine("来自" + retrunstr.Content);
channel.ShutdownAsync().Wait();
Console.WriteLine("任意键退出...");
Console.ReadKey();
}
}
}