Why do my server and client crash on startup?

I’m very new to Networking, so I’ve been trying to develop my own Server and Client to use with Unity. I of course did some copy and pasting to learn the basics, but now I’m trying to get a real grasp of how to accomplish what I am looking for. As for now, I just want to connect a client to a server(UDP), and get a confirmation that it is working before I continue.

My current issue is this:
Unity crashes immediately upon running the game.

Server:

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class Server
{
    private const int port = 8080;

    public static int Main()
    {
        //bool done = false;
        UdpClient listener = new UdpClient(port);
        IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, port);
        string receivedData;
        byte[] receivedBytes;

        try
        {
                Console.WriteLine("Waiting for broadcast...");
                receivedBytes = listener.Receive(ref groupEP);

                Console.WriteLine("Receiving broadcast from: {0}", groupEP.ToString());

                receivedData = Encoding.ASCII.GetString(receivedBytes, 0, receivedBytes.Length);
                Console.WriteLine("Data follow

{0}

", receivedData);
}

        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        listener.Close();
        return 0;
    }
}

Client:

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class Client
{
    public static void Main()
    {
        //Boolean done = false;
        Boolean exception_Thrown = false;

        Socket sending = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

        IPAddress sendTo = IPAddress.Parse("192.168.1.127");

        IPEndPoint sendEndPoint = new IPEndPoint(sendTo, 8080);

        Console.WriteLine("Enter text to broadcast");
        Console.WriteLine("Enter a blank line to exit the program");


        string sendText = "Success!";
        /*
        if (sendText.Length == 0)
        {
            done = true;
        }
        
        else
        {
        */
            byte[] sendBuffer = Encoding.ASCII.GetBytes(sendText);
            Console.WriteLine("Send to address: {0}, port: {1}", sendEndPoint, sendEndPoint.Port);

            try
            {
                sending.SendTo(sendBuffer, sendEndPoint);
            }

            catch (Exception send_Exception)
            {
                exception_Thrown = true;
                Console.WriteLine("Exception {0}", send_Exception);
            }

            if (!(exception_Thrown))
            {
                Console.WriteLine("Message has been sent to the broadcast address");
            }

            else
            {
                exception_Thrown = false;
                Console.WriteLine("The exception indicates the message was not sent");
            }
        //}
    }
}

The script I’m going to use to call the other scripts without MonoBehaviour:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class ServerManager : MonoBehaviour
{
    private GameObject netGameObject;
    private Server serverScript;
    private Client clientScript;
    //private float timer = 0.0f;
    //private float nextServerUpdate = 2.0f;
    //private bool runUpdate = true;
    //private bool s = false;

    // Start is called before the first frame update
    void Start()
    {
        netGameObject = this.gameObject;
        serverScript = new Server();
        clientScript = new Client();
        StartCoroutine(ServerUpdate(2f));
        //Server.Main();
        //Client.Main();
    }
    /*
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Y))
        {
            s = true;
        }
    }
    */
    private IEnumerator ServerUpdate(float waitTime)
    {
        while (true)
        {
            Server.Main();
            Debug.Log("Working");
            yield return new WaitForSeconds(waitTime);
        }
    }
}

I’ve been toying with various things for a while now, and I really need some help.
Things I’ve tested:
1. the coroutine freezes as soon as it hits Server.Main().
2. DIY timers react the same as coroutine.
3. while(true) loop in coroutine doesn’t appear to make a difference.
4. Server.Main() freezes even from start or awake, with all loops that I can find removed.
5. Client.Main() gives me the exact same problems.

Just a note: I have been avoiding Unity’s built in systems (UNET and the like) because networking is something I would really like to learn to manage for myself, where I could use it outside of Unity as well.

I would really appreciate any assistance with this, thanks in advance =)

For anyone interested in the answer (with a good, in depth explanation of some parts of it for beginners like me), the answer is here: unity - Why does my game crash on startup? - Game Development Stack Exchange

An additional question that is related, also with a very helpful answer: unity - Why can I only connect one client to my server? - Game Development Stack Exchange