* Added a timeout property to TCPConnection. Set it before calling -open, if you want a shorter timeout than the default.
* Made the utility function BLIPMakeError public.
5 // Created by Jens Alfke on 5/10/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
9 #import "BLIPConnection.h"
10 #import "BLIPRequest.h"
11 #import "BLIPProperties.h"
15 /* Private declarations and APIs for BLIP implementation. Not for use by clients! */
18 /* BLIP message types; encoded in each frame's header. */
20 kBLIP_MSG, // initiating message
21 kBLIP_RPY, // response to a MSG
22 kBLIP_ERR // error response to a MSG
25 /* Flag bits in a BLIP frame header */
27 kBLIP_TypeMask = 0x000F, // bits reserved for storing message type
28 kBLIP_Compressed= 0x0010, // data is gzipped
29 kBLIP_Urgent = 0x0020, // please send sooner/faster
30 kBLIP_NoReply = 0x0040, // no RPY needed
31 kBLIP_MoreComing= 0x0080, // More frames coming (Applies only to individual frame)
33 typedef UInt16 BLIPMessageFlags;
36 /** Header of a BLIP frame as sent across the wire. All fields are big-endian. */
38 UInt32 magic; // magic number (kBLIPFrameHeaderMagicNumber)
39 UInt32 number; // serial number of MSG
40 BLIPMessageFlags flags; // encodes frame type, "more" flag, and other delivery options
41 UInt16 size; // total size of frame, _including_ this header
44 #define kBLIPFrameHeaderMagicNumber 0x9B34F205
47 @interface BLIPConnection ()
48 - (void) _dispatchRequest: (BLIPRequest*)request;
49 - (void) _dispatchResponse: (BLIPResponse*)response;
53 @interface BLIPMessage ()
54 @property BOOL sent, propertiesAvailable, complete;
55 - (void) _setFlag: (BLIPMessageFlags)flag value: (BOOL)value;
60 @interface BLIPMessage ()
61 - (id) _initWithConnection: (BLIPConnection*)connection
63 flags: (BLIPMessageFlags)flags
66 - (BOOL) _writeFrameTo: (BLIPWriter*)writer maxSize: (UInt16)maxSize;
67 @property (readonly) SInt32 _bytesWritten;
68 - (void) _assignedNumber: (UInt32)number;
69 - (BOOL) _receivedFrameWithHeader: (const BLIPFrameHeader*)header body: (NSData*)body;
70 - (void) _connectionClosed;
74 @interface BLIPRequest ()
75 - (id) _initWithConnection: (BLIPConnection*)connection
77 properties: (NSDictionary*)properties;
81 @interface BLIPResponse ()
82 - (id) _initWithRequest: (BLIPRequest*)request;