private ServerGreeting PerformGreeting() { HashSet <AuthMethod> methods = new HashSet <AuthMethod> { 0 }; if (!string.IsNullOrEmpty(this.Username)) { methods.Add(AuthMethod.Username); } byte[] buffer = new ClientGreeting(methods).Serialize(); this.stream.Write(buffer, 0, buffer.Length); buffer = new byte[2]; this.stream.Read(buffer, 0, 2); return(ServerGreeting.Deserialize(buffer)); }
/// <summary> /// Performs the initial greeting. /// </summary> /// <returns>The greeting-message returned by the SOCKS5 server.</returns> /// <exception cref="Socks5Exception">The server returned invalid or /// unexpected data.</exception> ServerGreeting PerformGreeting() { var methods = new HashSet <AuthMethod>() { AuthMethod.None }; if (!String.IsNullOrEmpty(Username)) { methods.Add(AuthMethod.Username); } byte[] bytes = new ClientGreeting(methods).Serialize(); stream.Write(bytes, 0, bytes.Length); // Read the server's response. bytes = new byte[2]; stream.Read(bytes, 0, 2); return(ServerGreeting.Deserialize(bytes)); }