1
有沒有辦法將SSL添加到我的套接字?我只想使用我現有的代碼,但是我在互聯網上找到的所有代碼都是針對不同類型的實現。c#套接字使用Ssl
partial void btnConnectClicked(NSObject sender) {
try {
clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
lock (clientSocket) {
clientSocket.BeginConnect(new IPEndPoint(IPAddress.Loopback, 3333), new AsyncCallback(ConnectCallback), null);
}
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
partial void btnSendClicked(NSObject sender) {
try {
string text = tbText.StringValue;
byte[] buffer = Encoding.ASCII.GetBytes(text);
clientSocket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(SendCallback), null);
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
private void ConnectCallback(IAsyncResult AR) {
try {
clientSocket.EndConnect(AR);
SetEnabled();
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
private void SendCallback(IAsyncResult AR) {
try {
clientSocket.EndSend(AR);
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
我希望有人能幫助我
通過Socket使用SslStream。 –