This function can be used for connecting....

This function can be used to connect....

Are they natural and ways of saying the same thing?

Thanks.
Both are grammatical, but the second is much more natural to my ears.
Thanks, Barb, for your quick reply.