9 kMacSocket_TimeoutErr = -2
12 // Since MacSocket does busy waiting, I do a callback while waiting
14 typedef OSErr(*MacSocket_IdleWaitCallback) (void *);
16 // Call this before anything else!
18 OSErr MacSocket_Startup(void);
20 // Call this to cleanup before quitting
22 OSErr MacSocket_Shutdown(void);
24 // Call this to allocate a "socket" (reference number is returned in
26 // Note that inDoThreadSwitching is pretty much irrelevant right now, since I
28 // The inTimeoutTicks parameter is applied during reads/writes of data
29 // The inIdleWaitCallback parameter specifies a callback which is called
30 // during busy-waiting periods
31 // The inUserRefPtr parameter is passed back to the idle-wait callback
33 OSErr MacSocket_socket(int *outSocketNum, const Boolean inDoThreadSwitching,
34 const long inTimeoutTicks,
35 MacSocket_IdleWaitCallback inIdleWaitCallback,
38 // Call this to connect to an IP/DNS address
39 // Note that inTargetAddressAndPort is in "IP:port" format-- e.g.
42 OSErr MacSocket_connect(const int inSocketNum, char *inTargetAddressAndPort);
44 // Call this to listen on a port
45 // Since this a low-performance implementation, I allow a maximum of 1 (one!)
46 // incoming request when I listen
48 OSErr MacSocket_listen(const int inSocketNum, const int inPortNum);
50 // Call this to close a socket
52 OSErr MacSocket_close(const int inSocketNum);
54 // Call this to receive data on a socket
55 // Most parameters' purpose are obvious-- except maybe "inBlock" which
56 // controls whether I wait for data or return immediately
58 int MacSocket_recv(const int inSocketNum, void *outBuff, int outBuffLength,
59 const Boolean inBlock);
61 // Call this to send data on a socket
63 int MacSocket_send(const int inSocketNum, const void *inBuff,
66 // If zero bytes were read in a call to MacSocket_recv(), it may be that the
67 // remote end has done a half-close
68 // This function will let you check whether that's true or not
70 Boolean MacSocket_RemoteEndIsClosing(const int inSocketNum);
72 // Call this to see if the listen has completed after a call to
75 Boolean MacSocket_ListenCompleted(const int inSocketNum);
77 // These really aren't very useful anymore
79 Boolean MacSocket_LocalEndIsOpen(const int inSocketNum);
80 Boolean MacSocket_RemoteEndIsOpen(const int inSocketNum);
82 // You may wish to change the userRefPtr for a socket callback-- use this to
85 void MacSocket_SetUserRefPtr(const int inSocketNum, void *inNewRefPtr);
87 // Call these to get the socket's IP:port descriptor
89 void MacSocket_GetLocalIPAndPort(const int inSocketNum, char *outIPAndPort,
90 const int inIPAndPortLength);
91 void MacSocket_GetRemoteIPAndPort(const int inSocketNum, char *outIPAndPort,
92 const int inIPAndPortLength);
94 // Call this to get error info from a socket
96 void MacSocket_GetSocketErrorInfo(const int inSocketNum,
97 int *outSocketErrCode,
98 char *outSocketErrString,
99 const int inSocketErrStringMaxLength);