I have a calendar feature in my software application in which I can create events, tasks, appointments and other normal calendar features.
I want to have a feature where I can synchronize my calendar events to my iPhone or Android phone calendar apps. I found that I could use CalDAV protocol (RFC 4791) to implement this, but I am not sure how to go about it.
Do I have to create both a CalDAV server and client?
This is an excellent guide on how to write a CalDAV client: Building a CalDAV client.
Unless you have very special needs, you probably don't need to write a CalDAV server, there are plenty of them already.
Another useful resources is the CalDAV Home website of CalConnect (the standards organisation working on CalDAV).