Hmm, so you want to put a chat server in your iPhone app? It's certainly possible, and might make sense for very ad-hoc chats over bonjour, bluetooth, etc.
Unless you jailbreak the device, however, the server will not be able to run in the background (there are some tricks you can use to work around this, but it won't be reliable) - so after the user quits the chat app, the server will be gone.
Most of the time it's better to keep your servers in the cloud, where they belong.