#include "defs.h"
#include "rpc.h"
#include "funcs.h"

int
net_drain(fd)
int fd;
{
    short buf[3];

    buf[0] = FUNC_DRAIN;
    buf[1] = fd;
    (void)rpc_call(net_handle, sizeof buf, 4, buf);
    if (buf[0] < 0) {
	neterrno = buf[2];
	if (neterrno == NETERR_ERRNO)
	    map_errno(buf[1]);
	return -1;
    }
    return buf[0];
}

int
net_release(fd)
int fd;
{
    short buf[3];

    buf[0] = FUNC_RELEASE;
    buf[1] = fd;
    (void)rpc_call(net_handle, sizeof buf, 4, buf);
    if (buf[0] < 0) {
	neterrno = buf[2];
	if (neterrno == NETERR_ERRNO)
	    map_errno(buf[1]);
	return -1;
    }
    return buf[0];
}

int
net_eof(fd)
int fd;
{
    short buf[3];

    buf[0] = FUNC_EOF;
    buf[1] = fd;
    (void)rpc_call(net_handle, sizeof buf, 4, buf);
    if (buf[0] < 0) {
	neterrno = buf[2];
	if (neterrno == NETERR_ERRNO)
	    map_errno(buf[1]);
	return -1;
    }
    return buf[0];
}
