-(defun sendto (fd &rest options)
- (apply #'win32-sendto (fd->handle fd) options))
-
-(defun close (fd &rest options)
- (apply #'win32-close (fd->handle fd) options))
-
-(defun connect (fd &rest options)
- (apply #'win32-connect (fd->handle fd) options))
-
-(defun getpeername (fd &rest options)
- (apply #'win32-getpeername (fd->handle fd) options))
-
-(defun ioctl (fd &rest options)
- (apply #'win32-ioctl (fd->handle fd) options))
-
-(defun setsockopt (fd &rest options)
- (apply #'win32-setsockopt (fd->handle fd) options))
-
-(defun getsockopt (fd &rest options)
- (apply #'win32-getsockopt (fd->handle fd) options))
+(defun socket (af type proto)
+ (wsa-socket af type proto nil 0 WSA_FLAG_OVERLAPPED))
+
+;;; For historical reasons, the FFI functions declared in win32-constants
+;;; prepend "win32-" to the symbol names. Rather than break compatibility
+;;; for users depending on those names, wrap the misnamed functions in
+;;; correctly named ones...
+(macrolet ((define-socket-fd-arg-routines (&rest names)
+ `(progn
+ (declaim (inline ,@names))
+ ,@(loop for routine in names collect
+ `(defun ,routine (handle &rest options)
+ (apply #',(sb-int:symbolicate "WIN32-" routine)
+ handle options))))))
+ (define-socket-fd-arg-routines
+ bind getsockname listen recv recvfrom send sendto close connect
+ getpeername ioctl setsockopt getsockopt))
+
+(defun accept (handle &rest options)
+ (let ((handle (apply #'win32-accept handle options)))
+ (if (= handle -1)
+ -1
+ handle)))