Yes it's possible , check ChatGuard for the code. but self updating is not a good chose because it's not safe, you can add evil code anytime and all the servers with that plugin will download that version. And if the hosting website for your plugin is down, when the servers with the plugin restarts it can't download it.