0

Is there a way to reuse SSL socket connections on the iPhone. I'm seeing an extra 3-4 second overhead in doing SSL handshaking. I'm using NSURLconnection currently to do the API calls and each one of them is taking 4-5 seconds on Wifi. Any suggestions would be greatly appreciated.

2 Answers2

1

Are you asking how to "reuse" sockets for the same specific address and port? Or for different URLs?

If the former, just don't close the socket until you're absolutely sure you don't need it anymore.

If the latter, there's nothing you can do about that. The SSL certificate verification process is likely where you're getting the overhead from.

You'll need to add more context to your question if you want a more specific answer.

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128
0

you might want to establish an SSL connection an keep reusing it. Rather than make a new connection each time. There is definitely an overhead to SSL connections as well as handshaking. You cant get rid of the overhead from the encryption but the handshaking can be reduced by using NSStreams and keeping the connection open as you use it.

I have posted code and instructions on how to do it here: NSStream SSL on used socket

Community
  • 1
  • 1
anurodhp
  • 356
  • 5
  • 13