Monday, November 08, 2010 at 12:06 AM.

on recv_event(adrSelf) {
	<<I'm thinking here that I can just do a readStringFromStream and be all happy about it. 
	local {
		header = "";
	while not header {
		try {
			tcp.readStreamBytes(adrself^._socket, 6, 60, @header)}
		else {
			<<msg("looping" + clock.ticks())
			case true {
				tryerror contains "closed" {,tryerror);
				tryError contains "timed out" {
					<<Nothing Special, we just didn't get data in timeout seconds
			else {,tryerror)};
		<<This will loop till there is something on the port. 
			<<probably need to be nicer about it. 
	if header == "" {;
		return (false)};
	local {
		marker = char(header[1]);
		mtype = number(char(header[2]));
		seq = number(number(char(header[3]))*256 + number(char(header[4])));
		buflen = number(number(char(header[5]))*256 + number(char(header[6])))};
	<<(marker,mtype,seq,buflen) = struct.unpack("!sBhh",header)
	<<#get the info
	if not tcp.readStreamBytes(adrself^._socket, buflen, 3, @data) {};
	return ({mtype, string(data)});

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.