<commit_before>extern crate rosc;

fn main() {
    println!("hello");
}<commit_msg>Implement socket creation address parsing<commit_after>extern crate rosc;

use std::{net, env, process};

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() < 3 {
        println!("Usage ./receive IP PORT");
        process::exit(1);
    }

    let addr: net::Ipv4Addr = parse_ip_v4(&args[1]);
    let port: u16 = args[2]
                        .parse()
                        .ok()
                        .expect("PORT must be in range [0, 65535]!");

    let sock = net::UdpSocket::bind((addr, port));
    println!("Listening to {}:{}", addr, port);
    drop(sock);
}

fn parse_ip_v4(raw_addr: &String) -> net::Ipv4Addr {
    let octets: Vec<u8> = raw_addr.splitn(4, '.')
                                  .map(|octet| {
                                      octet.parse::<u8>()
                                      .ok()
                                      .expect("Octet must be in range [0, 255]")
                                  })
                                  .collect();
    net::Ipv4Addr::new(octets[0], octets[1], octets[2], octets[3])
}
{'fraction_non_alphanumeric': 0.1568627450980392, 'fraction_numerical': 0.023870417732310314, 'mean_word_length': 1.5139186295503213, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2598252', 'n_tokens_mistral': 374, 'n_tokens_neox': 352, 'n_words': 80}