manifestinteractive/easyapns — pull request #21 by ptekchand (2012-03-27 18:16:00+00:00)
Title: Re-using sockets

- SSL Sockets(production/sandbox) are shared across multiple notifications.
- Feedback service is only read once every batch.
- Response from APNS is handled (select timeout gotcha)
- Common loop helper _iterateMessages de-duplicates code in _fetchMessages and _flushMessages

Previously a socket was connected and closed for each notification that was sent.
Additionally, the feedback service was checked after every notification as well (which was another socket connection followed by a read). This is now called once after a batch has been sent.
The response from APNS is also read and handled. It's read after every individual write ([warning]on a 1 second select timeout). Overall, the 'cost' of this read should easily be offset by the read on the feedback service which now happens only once per batch.