Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)
CVMichael...
I'm trying to develop your application about winsock send file.
if Server Runn, it will send his IP to Client, so when client need to send a File he just choose an IP of the server that he want to send. without type the IP
when any another 2 PC running U'r winsock sever application. All winsock server
send(Broadcast) their IP addres to PC whose Running Winsock Client(Bind).
I found a code Like This:
' server side
Private Sub Command1_Click()
On Error Resume Next
For x = 420 To 440
Winsock1.Close
Winsock1.RemoteHost = "255.255.255.255"
Winsock1.RemotePort = x
Winsock1.SendData winsock1.LocalIp
Next
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Winsock1.Close
Me.Caption = "BoardCast Server"
End Sub
Private Sub Timer1_Timer()
Command1_Click
End Sub
' Client Side
Dim IP As Integer
Private Sub Form_Load()
Me.Caption = "BoardCast Client"
IP = 420
On Error GoTo errIP
Winsock1.Bind IP
Exit Sub
errIP:
IPIncrease
Exit Sub
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error GoTo errIP
Dim strData As String
Winsock1.GetData strData
Text1.Text = strData ' <-----------Here My problem, listen only 1 IP if any another aplication winsock server run, his IP showed too at here(text1.text)
Exit Sub
errIP:
IPIncrease
End Sub
Sub IPIncrease()
On Error GoTo errIP
IP = IP + 1
Winsock1.Close
Winsock1.Bind IP
Exit Sub
errIP:
IPIncrease
End Sub
Last edited by Aan2702; May 18th, 2008 at 01:11 PM.