;Protocol family
AF_UNSPEC               = 0
AF_LOCAL                = 1
AF_INET4                = 2
AF_INET6                = 10
AF_PPP                  = 777           ; FIXME

AF_INET = AF_INET4

PF_UNSPEC  =  AF_UNSPEC
PF_LOCAL   =  AF_LOCAL
PF_INET4   =  AF_INET4
PF_INET6   =  AF_INET6
PF_PPP     =  AF_PPP

PF_INET    =  AF_INET

; Socket types
SOCK_STREAM             = 1
SOCK_DGRAM              = 2
SOCK_RAW                = 3

; Socket level
SOL_SOCKET              = 0xffff

; Socket options
SO_ACCEPTCON            = 1 shl 0
SO_BROADCAST            = 1 shl 1
SO_DEBUG                = 1 shl 2
SO_DONTROUTE            = 1 shl 3
SO_KEEPALIVE            = 1 shl 4
SO_OOBINLINE            = 1 shl 5
SO_REUSEADDR            = 1 shl 6
SO_REUSEPORT            = 1 shl 7
SO_USELOOPBACK          = 1 shl 8
SO_BINDTODEVICE         = 1 shl 9

SO_NONBLOCK             = 1 shl 31

SO_RCVBUF = 0
SO_SNDBUF = 0
SO_RCVTIMEO = 0
SO_SNDTIMEO = 0
SO_LINGER = 0

SO_RCVBUF       = 0
SO_SNDBUF       = 0
SO_RCVTIMEO     = 0
SO_SNDTIMEO     = 0
SO_LINGER       = 0


; Socket States
SS_NOFDREF              = 0x0001        ; no file table ref any more
SS_ISCONNECTED          = 0x0002        ; socket connected to a peer
SS_ISCONNECTING         = 0x0004        ; in process of connecting to peer
SS_ISDISCONNECTING      = 0x0008        ; in process of disconnecting
SS_CANTSENDMORE         = 0x0010        ; can't send more data to peer
SS_CANTRCVMORE          = 0x0020        ; can't receive more data from peer
SS_RCVATMARK            = 0x0040        ; at mark on input
SS_ISABORTING           = 0x0080        ; aborting fd references - close()
SS_RESTARTSYS           = 0x0100        ; restart blocked system calls
SS_ISDISCONNECTED       = 0x0800        ; socket disconnected from peer

SS_ASYNC                = 0x1000        ; async i/o notify
SS_ISCONFIRMING         = 0x2000        ; deciding to accept connection req
SS_MORETOCOME           = 0x4000

SS_BLOCKED              = 0x8000


SOCKET_MAXDATA          = 4096*64     ; must be 4096*(power of 2) where 'power of 2' is at least 8


; Error Codes
ENOBUFS                 = 1
EINPROGRESS             = 2
EOPNOTSUPP              = 4
EWOULDBLOCK             = 6
ENOTCONN                = 9
EALREADY                = 10
EINVAL                  = 11
EMSGSIZE                = 12
ENOMEM                  = 18
EADDRINUSE              = 20
ECONNREFUSED            = 61
ECONNRESET              = 52
EISCONN                 = 56
ETIMEDOUT               = 60
ECONNABORTED            = 53
