/*
- * Copyright (c) 2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2014 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_LICENSE_HEADER_END@
*/
+
/* CFSocket.h
- Copyright (c) 1999-2009, Apple Inc. All rights reserved.
+ Copyright (c) 1999-2014, Apple Inc. All rights reserved.
*/
#if !defined(__COREFOUNDATION_CFSOCKET__)
#define __COREFOUNDATION_CFSOCKET__ 1
-#include <TargetConditionals.h>
-
-#if TARGET_OS_WIN32
-typedef uintptr_t CFSocketNativeHandle;
-#else
-typedef int CFSocketNativeHandle;
-#endif
-
#include <CoreFoundation/CFRunLoop.h>
#include <CoreFoundation/CFData.h>
+CF_IMPLICIT_BRIDGING_ENABLED
CF_EXTERN_C_BEGIN
typedef struct __CFSocket * CFSocketRef;
*/
/* Values for CFSocketError */
-enum {
+typedef CF_ENUM(CFIndex, CFSocketError) {
kCFSocketSuccess = 0,
- kCFSocketError = -1,
- kCFSocketTimeout = -2
+ kCFSocketError = -1L,
+ kCFSocketTimeout = -2L
};
-typedef CFIndex CFSocketError;
typedef struct {
SInt32 protocolFamily;
} CFSocketSignature;
/* Values for CFSocketCallBackType */
-enum {
+typedef CF_OPTIONS(CFOptionFlags, CFSocketCallBackType) {
kCFSocketNoCallBack = 0,
kCFSocketReadCallBack = 1,
kCFSocketAcceptCallBack = 2,
kCFSocketDataCallBack = 3,
- kCFSocketConnectCallBack = 4
-#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
- ,
+ kCFSocketConnectCallBack = 4,
kCFSocketWriteCallBack = 8
-#endif
};
-typedef CFOptionFlags CFSocketCallBackType;
-#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
/* Socket flags */
enum {
kCFSocketAutomaticallyReenableReadCallBack = 1,
kCFSocketAutomaticallyReenableAcceptCallBack = 2,
kCFSocketAutomaticallyReenableDataCallBack = 3,
kCFSocketAutomaticallyReenableWriteCallBack = 8,
-#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
- kCFSocketLeaveErrors = 64,
-#endif
+ kCFSocketLeaveErrors CF_ENUM_AVAILABLE(10_5, 2_0) = 64,
kCFSocketCloseOnInvalidate = 128
};
-#endif
typedef void (*CFSocketCallBack)(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info);
/* If the callback wishes to keep hold of address or data after the point that it returns, then it must copy them. */
CFStringRef (*copyDescription)(const void *info);
} CFSocketContext;
+#if TARGET_OS_WIN32
+typedef uintptr_t CFSocketNativeHandle;
+#else
+typedef int CFSocketNativeHandle;
+#endif
+
CF_EXPORT CFTypeID CFSocketGetTypeID(void);
CF_EXPORT CFSocketRef CFSocketCreate(CFAllocatorRef allocator, SInt32 protocolFamily, SInt32 socketType, SInt32 protocol, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context);
CF_EXPORT CFSocketRef CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context);
CF_EXPORT CFSocketRef CFSocketCreateWithSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context);
+/* CFSocketCreateWithSocketSignature() creates a socket of the requested type and binds its address (using CFSocketSetAddress()) to the requested address. If this fails, it returns NULL. */
CF_EXPORT CFSocketRef CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout);
-/* CFSocketCreateWithSignature creates a socket of the requested type and binds its address (using CFSocketSetAddress) to the requested address. If this fails, it returns NULL. CFSocketCreateConnectedToSignature creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress). If this fails, it returns NULL. */
+/* CFSocketCreateConnectedToSocketSignature() creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress()). If this fails, it returns NULL. */
CF_EXPORT CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address);
CF_EXPORT CFSocketError CFSocketConnectToAddress(CFSocketRef s, CFDataRef address, CFTimeInterval timeout);
CF_EXPORT CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, CFSocketRef s, CFIndex order);
-#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
CF_EXPORT CFOptionFlags CFSocketGetSocketFlags(CFSocketRef s);
CF_EXPORT void CFSocketSetSocketFlags(CFSocketRef s, CFOptionFlags flags);
CF_EXPORT void CFSocketDisableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes);
CF_EXPORT void CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes);
-#endif
+
/* For convenience, a function is provided to send data using the socket with a timeout. The timeout will be used only if the specified value is positive. The address should be left NULL if the socket is already connected. */
CF_EXPORT CFSocketError CFSocketSendData(CFSocketRef s, CFDataRef address, CFDataRef data, CFTimeInterval timeout);
CF_EXPORT const CFStringRef kCFSocketRetrieveCommand;
CF_EXTERN_C_END
+CF_IMPLICIT_BRIDGING_DISABLED
#endif /* ! __COREFOUNDATION_CFSOCKET__ */