Browse Source

Initialize and shutdown sockets on Windows

master
Macoy Madson 2 months ago
parent
commit
f1329e97ce
  1. 19
      src/Network.cake

19
src/Network.cake

@ -2,14 +2,29 @@
(export
(comptime-cond
('Windows
(c-import "<string.h>"
"<winsock2.h>" "<stdio.h>"))
(c-import "<string.h>" "<winsock2.h>" "<stdio.h>"))
(true
(c-import "<string.h>"
"<sys/socket.h>" "<sys/types.h>" "<unistd.h>"
"<netinet/tcp.h>" "<netinet/in.h>" "<netdb.h>")))
(def-type-alias-global socket-type int))
;; For WORD, MAKEWORD
(c-import "<windows.h>")
(defun network-initialize (&return int)
(comptime-cond
('Windows
(var requested-version WORD (MAKEWORD 2 2))
(var sockets-data WSADATA)
(return (WSAStartup requested-version (addr sockets-data)))))
(return 0))
(defun network-shutdown ()
(comptime-cond
('Windows
(WSACleanup))))
(comptime-cond
('Windows
(import "CHelpers.cake")

Loading…
Cancel
Save