public void Init() { // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) { Services = { ModbusTCP.BindService(new ModbusImpl()) }, Ports = { { Hostname, Port, ServerCredentials.Insecure } } }; server.Start(); channel = new Channel(Hostname, Port, ChannelCredentials.Insecure); client = new ModbusTCP.ModbusTCPClient(channel); }
public static void Main(string[] args) { var server = new Server { Services = { ModbusTCP.BindService(new ModbusImpl()) }, Ports = { new ServerPort(Hostname, Port, ServerCredentials.Insecure) } }; server.Start(); Console.WriteLine("Modbus gRPC server listening on port " + Port); // Console.WriteLine("Press any key to stop the server..."); // Console.ReadKey(); // TODO: Fix this mock later while (true) { Thread.Sleep(1000); } server.ShutdownAsync().Wait(); }