int oe_socket_d(uint64_t devid, int domain, int type, int protocol)
{
    int ret = -1;
    int sd;
    oe_fd_t* sock = NULL;
    oe_device_t* device;

    if (devid == OE_DEVID_NONE)
    {
        /* Only one device today. */
        devid = OE_DEVID_HOST_SOCKET_INTERFACE;
    }

    if (!(device = oe_device_table_get(devid, OE_DEVICE_TYPE_SOCKET_INTERFACE)))
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!(sock = device->ops.socket.socket(device, domain, type, protocol)))
    {
        OE_RAISE_ERRNO_MSG(
            oe_errno,
            "devid=%ld domain=%d type=%d protocol=%d",
            devid,
            domain,
            type,
            protocol);
        goto done;
    }

    if ((sd = oe_fdtable_assign(sock)) == -1)
        OE_RAISE_ERRNO(oe_errno);

    ret = sd;
    sock = NULL;

done:

    if (sock)
        sock->ops.fd.close(sock);

    return ret;
}
int oe_socket_d(uint64_t devid, int domain, int type, int protocol)
{
    int ret = -1;
    int sd;
    oe_fd_t* sock = NULL;
    oe_device_t* device;

    if (devid == OE_DEVID_NONE)
    {
         
        devid = OE_DEVID_HOST_SOCKET_INTERFACE;
    }

    if (!(device = oe_device_table_get(devid, OE_DEVICE_TYPE_SOCKET_INTERFACE)))
        OE_RAISE_ERRNO(OE_EINVAL);

    if (!(sock = device->ops.socket.socket(device, domain, type, protocol)))
    {
        OE_RAISE_ERRNO_MSG(
            oe_errno,
            "devid=%ld domain=%d type=%d protocol=%d",
            devid,
            domain,
            type,
            protocol);
        goto done;
    }

    if ((sd = oe_fdtable_assign(sock)) == -1)
        OE_RAISE_ERRNO(oe_errno);

    ret = sd;
    sock = NULL;

done:

    if (sock)
        sock->ops.fd.close(sock);

    return ret;
}