# include <kernel/kernel.h>
# include <kernel/user.h>
# include <kernel/net.h>

inherit LIB_PORT;

/*
 * NAME:        create()
 * DESCRIPTION: initialize port object
 */
static void create(int clone)
{
    if (clone) {
        ::create();
    }
}

/*
 * NAME:        listen()
 * DESCRIPTION: start listening on a port
 */
void listen(string protocol, int port)
{
#ifndef SYS_NETWORKING
    if (previous_program() == DRIVER) {
#else
    if (previous_program() == DRIVER || previous_program() == USERD) {
#endif
        ::open_port(protocol, port);
    }
}

/*
 * NAME:        open_connection()
 * DESCRIPTION: don't return a user object, select it by first line of input
 */
static object open_connection(string ipaddr, int port)
{
    return nil;
}

void open(int port) {
    ::open(allocate(DRIVER->query_tls_size()),port);
}

object connection(string ip, int port) {
    ::connection(allocate(DRIVER->query_tls_size()),ip,port);
}

