gRPC Core sets SO_REUSEPORT by default and I believe that's why you are running into this. To disable this, you can set the channel argument GRPC_ARG_ALLOW_REUSEPORT <https://source.corp.google.com/piper///depot/google3/third_party/grpc/include/grpc/impl/codegen/grpc_types.h;bpv=1;bpt=1;rcl=348724940;l=295?gsn=GRPC_ARG_ALLOW_REUSEPORT&gs=kythe%3A%2F%2Fgoogle3%3Flang%3Dc%252B%252B%3Fpath%3Dthird_party%2Fgrpc%2Finclude%2Fgrpc%2Fimpl%2Fcodegen%2Fgrpc_types.h%23GRPC_ARG_ALLOW_REUSEPORT%2523m%254013727> to 0.
On Thursday, December 3, 2020 at 4:16:02 PM UTC-8 hek...@gmail.com wrote: > int bound_port=0; > std::string server_address("0.0.0.0:50051"); > builder.AddListeningPort(server_address, > grpc::SslServerCredentials(ssl_options) &bound_port); > builder.RegisterService(&service); > std::unique_ptr server(builder.BuildAndStart()); > if(bound_port == 0) { cout<<"port already in use!" << endl; } > > I don't know why above code is not work, the bound_port return always is > 50051, I can't get 0 as expected when port already in use. > > Thanks for your help in advance! > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/9a520082-e5f4-43a6-b204-a2aeb47c30a3n%40googlegroups.com.