Reputation: 2834
Is there a way to add SSL to my sockets? I just want to use my existing code, but all i found on the internet was for a different type of implementation.
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);
}
}
I hope anyone can help me
Upvotes: 2
Views: 860
Reputation: 40858
Everything I've read says to use SslStream.
This guy wrote a helper class around the Socket class for using SSL, but he admits in that post that SslStream would have made life easier.
Upvotes: 2