An iPhone app, connecting to a remote server via TCP. The use scenarios are:
Tapbots solved this problem with Pastebot by prompting the user to run a silent background audio track at all times.
Note that Apple frowns on using hacks like employing the background audio or VOIP APIs to keep non audio or VOIP apps running (as evidenced by the 'workaround' described in the article above) so dabbling with these techniques risks rejection at the point of submission.
Unfortunately, though, there is no legal API to keep a connection alive in the background. Perhaps they'll introduce one in a future update to iOS, but you might consider submitting a feature request to voice your support for it.