I am trying to use the following piece of code to connect to a time server and attain the time but have had no luck:

Dim ntpServer As String = "time.windows.com"
Dim ntpData(47) As Byte

Dim addresses = Dns.GetHostEntry(ntpServer).AddressList

Dim EndP As IPEndPoint = New IPEndPoint(addresses(0), 123)

Dim soc As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)


soc.Connect(EndP)

soc.Send(ntpData)


soc.Receive(ntpData)


soc.Close()

Stepping through the program I can't get past the following line of code soc.Receive(ntpData). What am I doing wrong?

Thanks