[Symbian-hacks] Socket Programming sucks ass

Christopher Schmidt
Tue Jan 17 10:45:54 EST 2006


On Tue, Jan 17, 2006 at 03:26:18PM +0000, Nick Burch wrote:
> Assuming your GPS is like mine, and always sends a complete sentence (or a 
> few) at a time, then try something like:
> 
> to_ignore = sock.read(4096)

This is basically the path I took. Instead of just reading some
arbitrary amount of data, however, I used the 'select' module to find
out if the socket had data to read, and if so, I pulled it off the end.
Since I'm working with sticking a urllib request inbetween reads, the
data stored in the socket can sometimes approach 16k rather than 1-4, so
I needed to take a slightly better solution.

> If it doesn't end on a new line though, you'll need to discard the next 
> (part) sentence you read normally, since it'll be missing its start

The code I'm using already does this - reading data until it hits the
first $.

I'll drop the new code to the list in a bit - this is code for
cellstumbling, btw.

-- 
Christopher Schmidt
Web Developer


More information about the Symbian-hacks mailing list