【发布时间】:2016-04-30 01:40:43
【问题描述】:
有没有办法将 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。