
header "sys" as sys

#if OS != win
use io
#end

class Socket {
    static fn new_tcp(host: String, port: u16) SocketTCP !init_error {
        return SocketTCP.new(host, port) ! { throw init_error }
    }

    static fn close(fd: FD) void {
        #if OS == win
        sys:closesocket(fd.@cast(uint))
        #else
        sys:shutdown(fd.to(i32), sys:O_RDWR)
        io:close(fd)
        #end
    }
}
