<commit_before>import net/[berkeley, Socket, Address, DNS, Exceptions, utilities]
import io/[Reader, Writer]

/**
    A DATAGRAM based socket interface.
 */
UDPSocket: class extends Socket {
    remote: SocketAddress

    /**
        Initialize the socket, do not bind to any IP or port.
        Can be used with 
    */
    init: func() {}

    /**
        Initialize the socket

        :param ip: The IP, for now it can NOT be a hostname (TODO: This is a bug! Fix it!)
        :param port: The port, for example 8080, or 80.
    */
    init: func ~ipPortAndBufLength(ip := "0.0.0.0", port: Int) {
        super(remote family(), SocketType DATAGRAM, 0)
        type = ipType(ip)
        super(type, SocketType STREAM, 0)
        bind(ip, port)
    }

    /**
        Bind a local port to the socket.<commit_msg>Derp? There was no buffer length in that function at all! Bahahaha<commit_after>import net/[berkeley, Socket, Address, DNS, Exceptions, utilities]
import io/[Reader, Writer]

/**
    A DATAGRAM based socket interface.
 */
UDPSocket: class extends Socket {
    remote: SocketAddress

    /**
        Initialize the socket, do not bind to any IP or port.
        Can be used with 
    */
    init: func() {}

    /**
        Initialize the socket

        :param ip: The IP, for now it can NOT be a hostname (TODO: This is a bug! Fix it!)
        :param port: The port, for example 8080, or 80.
    */
    init: func ~ipPort(ip := "0.0.0.0", port: Int) {
        super(remote family(), SocketType DATAGRAM, 0)
        type = ipType(ip)
        super(type, SocketType STREAM, 0)
        bind(ip, port)
    }

    /**
        Bind a local port to the socket.
{'fraction_non_alphanumeric': 0.10797840431913618, 'fraction_numerical': 0.014397120575884824, 'mean_word_length': 2.2578125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1267275', 'n_tokens_mistral': 553, 'n_tokens_neox': 514, 'n_words': 200}