A couple things... I'm no expert on this so, take it for what it's worth...
1) ntpData is empty when you send it... don't you need to send something?
2 )I notice in the examples online for the Send and Recieve methods, they return an integer representing the number of bytes sent....
if you change your code similarly:
As to what to send to the server in the first place? That I do not know.Code: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) Dim i as integer = soc.Send(ntpData) 'If you check i here... I bet it's zero because the array was empty. 'Since nothing was sent, the server doesn't know to send anything back... so the receive hangs... i = soc.Receive(ntpData) soc.Close()
Documentation & example: http://msdn.microsoft.com/en-us/library/w93yy28a.aspx
-tg




Reply With Quote
