// only call before Start() public int AddPort(string addr, ServerCredentials credentials) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return handle.AddPort(addr, nativeCredentials); } }
// only call before Start() public int AddListeningPort(string addr, ServerCredentials credentials) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(addr, nativeCredentials)); } }
/// <summary> /// Add a secure port on which server should listen. /// Only call this before Start(). /// </summary> public int AddListeningPort(string addr, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(addr, nativeCredentials)); } } }
private int AddListeningPortInternal(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); if (credentials != null) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return(handle.AddListeningPort(address, nativeCredentials)); } } else { return(handle.AddListeningPort(address)); } } }
private int AddListeningPortInternal(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); if (credentials != null) { using (var nativeCredentials = credentials.ToNativeCredentials()) { return handle.AddListeningPort(address, nativeCredentials); } } else { return handle.AddListeningPort(address); } } }
/// <summary> /// Add a port on which server should listen. /// Only call this before Start(). /// </summary> /// <returns>The port on which server will be listening.</returns> /// <param name="host">the host</param> /// <param name="port">the port. If zero, an unused port is chosen automatically.</param> public int AddPort(string host, int port, ServerCredentials credentials) { lock (myLock) { Preconditions.CheckNotNull(credentials); Preconditions.CheckState(!startRequested); var address = string.Format("{0}:{1}", host, port); using (var nativeCredentials = credentials.ToNativeCredentials()) { if (nativeCredentials != null) { return handle.AddSecurePort(address, nativeCredentials); } else { return handle.AddInsecurePort(address); } } } }