Hi,
I have used both ODBC and DMO functions to locate SQL servers on our network but both are really slow and not allways complete. I have found a bit of code that just uses a "simple" UDP broadcast to get the server responses but I can't get it working, thought I would just be able to modify the echo client in samples but got no responses at all.
c# code
complete code is here http://www.codeproject.com/KB/databa...l_servers.aspx
sorry URL not working for me today
Can anyone point me in the right direction ?
N.
I have used both ODBC and DMO functions to locate SQL servers on our network but both are really slow and not allways complete. I have found a bit of code that just uses a "simple" UDP broadcast to get the server responses but I can't get it working, thought I would just be able to modify the echo client in samples but got no responses at all.
c# code
Code:
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp ); // For .Net v 1.1 the options are cumbersome & hidden. socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000); // For .Net v 2.0 it's a bit simpler // socket.EnableBroadcast = true; // for .Net v2.0 // socket.ReceiveTimeout = 3000; // for .Net v2.0 IPEndPoint ep = new IPEndPoint(IPAddress.Broadcast, 1434); byte[] msg = new byte[] { 0x02 }; socket.SendTo(msg, ep);
sorry URL not working for me today
Can anyone point me in the right direction ?
N.
Comment