Question: Is there a way to find available MySQL Server via broadcast in the network using Win-sockets?
I have some data and want to send it to the SQL server. The user should see all available SQL server in a list, can chosen one (don't care MSSQL or MySQL) and the program will store the data automatically in the right way to the database. Here is the abbreviated sample to find all MSSQL servers available in the network (written in Borland Delphi (Win32)). How looks the code (IP-address and port) for MySQL? procedure ShowMSSQLServer; const Address='255.255.255.255'; begin //create a socket DBSocket:=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); //declare call back routine WSAAsyncSelect(DBSocket,self.Handle,CM_MSSQLCallBack,FD_READ); //setup SNDBUF:=0; TCPNODELAY:=1; BROADCAST:=1; setsockopt(DBSocket,SOL_SOCKET,SO_SNDBUF,PChar(@SNDBUF),sizeof(SNDBUF)); setsockopt(DBSocket,SOL_SOCKET,TCP_NODELAY,PChar(@TCPNODELAY),sizeof(TCPNODE LAY)); setsockopt(DBSocket,SOL_SOCKET,SO_BROADCAST,PChar(@BROADCAST),sizeof(BROADCA ST)); hostaddr.sin_family :=AF_INET; hostaddr.sin_port :=htons(1434); hostaddr.sin_addr.s_addr:=inet_addr(PChar(Address)); buf:=#02; //ping //ask all maschines sendto(DBSocket,buf,1,0,hostaddr,sizeof(hostaddr)); end;