Socket.gram not connecting to provided IP address or local network

I was coding a C# application on windows forms where I have udp sockets of type socket.dgram, I have a client and server module running where both sides use socket.connect() to connect to each other, the function seems to run perfectly when provided with the localhost ip '' but as soon as I provide it with a local network ip i.e '', socket.connect() returns an exception of 'can not connect to unreachable network', I can not seem to find it to run on the local network ip or anything that is not local host.

I have tried running the application with

  • Turning off my firewall
  • Pinging my system with whatever system I try to run my modules on (pings successfully)
  • Tried to run the application in admin mode

Following is my code where it provides an exception

--------------Client side-------------------

private void RequestB_Click(object sender, EventArgs e)
        Tep = new IPEndPoint(IPAddress.Parse(SIP.Text), 
        client.Connect(Tep); // exception here
        Form2 frm = new Form2(client, Tep, port, nm);


-----------Server Side---------------------

private void ClientC(int no)
        epClient = new IPEndPoint(IPAddress.Parse(CAIP.Text), 
        buffer = new byte[1500];
        srvr.Connect(epClient); //------------> exception here
        srvr.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, 
ref epClient, new AsyncCallback(MessageCallback), buffer);
        string msg;
        ClientList[no] = epClient;

        if (srvr.Connected != true)
            Socket srvr1 = new Socket(AddressFamily.InterNetwork, 
SocketType.Dgram, ProtocolType.Udp);
SocketOptionName.ReuseAddress, true);
            msg = GetLocalIP();
            IPEndPoint epLocal = new 
IPEndPoint(IPAddress.Parse(GetLocalIP()), PN);
            if (srvr1.Connected == true)
                SendmessageI(CC, srvr1);
                //ChatLog.Items.Add("[ " + DateTime.Now.ToLongTimeString() + 
"] Server accepted Client [" + CC + "]'s request");
                string msg1 = "[ " + DateTime.Now.ToLongTimeString() + "] 
Client[" +no + "] has entered chatroom: ";
                byte[] recievedData = new byte[1500];

                ASCIIEncoding aEncoding = new ASCIIEncoding();
                string recievedMsg = aEncoding.GetString(recievedData);
                while (srvr1.Connected == true)
                    buffer = new byte[1500];
                    srvr1.BeginReceiveFrom(buffer, 0, buffer.Length, 
SocketFlags.None, ref ClientList[no], new AsyncCallback(MessageCallback), 
            else if (srvr1.Connected != true)
                while (srvr1.Connected != true)

Exception type:

System.Net.Sockets.SocketException: 'A socket operation was attempted to an unreachable network'