chat 2 subnets

vgopalap

Member
Joined
Dec 27, 2011
Messages
6
Programming Experience
Beginner
I think this is the right forum where Iam posting. Iam sorry if this is a wrong one.

I have a lan messenger designed in vb.net 2008 and its up and running fine in my subnet and user's are able to chat and transfer files. now my problem is that we have 2 subnets in our office and Iam not sure how to get the IP addresses of the other subnet and be able to chat with those users as well. Any help would be very much helpful to me. Below is the code which Iam using to get the IP of the local system

Private Function GetLocalIP() As System.Net.IPAddress
        Dim netIF As System.Net.NetworkInformation.NetworkInterface() = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
        Dim myIP As System.Net.NetworkInformation.UnicastIPAddressInformation
        Dim ipProp As System.Net.NetworkInformation.IPInterfaceProperties
        Dim myIPCol As System.Net.NetworkInformation.UnicastIPAddressInformationCollection
        Dim i As Integer
        If Options.localIF = -1 Then
            For i = 0 To UBound(netIF)
                If netIF(i).OperationalStatus = Net.NetworkInformation.OperationalStatus.Up Then
                    ipProp = netIF(i).GetIPProperties()
                    myIPCol = ipProp.UnicastAddresses()
                    For Each myIP In myIPCol
                        If myIP.Address.AddressFamily <> Net.Sockets.AddressFamily.InterNetworkV6 Then
                            If System.Net.IPAddress.IsLoopback(myIP.Address) = False Then
                                SetBcastAddress(i, myIP.Address)
                                Return myIP.Address
                            End If
                        End If
                    Next myIP
                End If
            Next i
            Return Nothing
        Else
            If netIF(Options.localIF).OperationalStatus = Net.NetworkInformation.OperationalStatus.Up Then
                ipProp = netIF(Options.localIF).GetIPProperties()
                myIPCol = ipProp.UnicastAddresses()
                For Each myIP In myIPCol
                    SetBcastAddress(Options.localIF, myIP.Address)
                    Return myIP.Address
                Next myIP
            End If
            Return Nothing
        End If
    End Function


Thanks in advance.
 
Last edited by a moderator:
IPv4 broadcast can be calculated from IP/submask for each IPv4 in UnicastAddresses for each network interface.
 
Hello John,

Thank you very much for replying. Can you just give an example because I am getting confused in calculating IP of other subnet.

Thanks in advance
 
I'm not sure what you're asking for now because you have already posted the code to do so yourself.
 
Back
Top