dcsimg
Results 1 to 15 of 15

Thread: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    I attached a Client and a Server program, a simple Chat program demonstrating how to connect to the server without knowing the server's IP.

    This is done by broadcasting a message from the client to the entire network, when server receives the message, server will broadcast another message giving it's IP and port number to use to connect to it. When client receives the server's message, it knows where to connect to using TCP connection.

    Here's Pseudo code on what's going on (the messages that are sent back and forth)

    Client broadcasts: "Where are you ?" (Could be anything, this is just an example)
    Server receives message
    Server broadcasts: "IP=192.128.0.1, Port=8888" (the IP and port # are just examples)
    Client receives server's message, and knows where to connect to
    Client connects to server using TCP
    Attached Files Attached Files

  2. #2
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    990

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    hi
    thanks for your implementation really good.
    i do i connect to a server(vb winsock) from outside the lan. that is if my server is located in my computer in my work place which is behind a router or which is in a lan network . is there any way to connect to this server from my home intrernet enabled computer

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Using this method you cannot go outside the local network because the router will not pass UDP broadcasts...

    You need a DNS name for your home computer, then you can connect to it from anywhere...

  4. #4
    New Member
    Join Date
    Feb 2008
    Posts
    4

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Hi. Im interested to use winsock send file via internet. behind router
    how can I setting up dns for my computer..

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Hi Aan2702, welcome to the forums

    I personally use this one: http://www.no-ip.com/ , it's free...

  6. #6
    New Member
    Join Date
    Feb 2008
    Posts
    4

    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
    Attached Files Attached Files
    Last edited by Aan2702; May 18th, 2008 at 01:11 PM.

  7. #7
    New Member
    Join Date
    Feb 2008
    Posts
    4

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    CMichael..
    I've been use your application Send File using winsock, to send via internet.
    and I've been set my router DNS to No-IP here's mine http://aan.redirectme.net

    I run the server application and Client application at the same PC.

    and From Client side I type Remote host = aan.redirectme.net, with remote port = 80. And it's work but not 100% compleate.

    here my print Screen http://img218.imageshack.us/my.php?i...7125407rc7.jpg

    Please help what's the problem..about this CMichael.

    ehmm..maybe we have to paid on http://www.no-ip.com/

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Regarding running multiple servers.... well... you are not supposed to... you are supposed to run only one server, and multiple clients.

    But if you want to fix the problem, simply don't accept any new connections if you are already connected.

    About the file transfer program, it works fine on my computer, so there is nothing I can do here to fix your problem. You should debug & find where the problem occurs by yourself, then try to fix it...

    And about no-ip.com, I've been using it for a few years, and I did not pay at all.... of course they offer the option that if you pay you get more features, but if you just want a DNS name, then you don't have to pay... Right on the main page it says "No-IP Free"

  9. #9
    New Member
    Join Date
    Feb 2008
    Posts
    4

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Thank's For Replay My question CVMichael..

    I'm still confused to using No-IP.
    or maybe I'm wrong because..on my NO-IP account, I add a host called aan.redirectme.net (I'm direct incoming packet from my external IP on port 80 into my PC with port 8686)

    I hope when You have a free time , you can showed me little experiment about Your aplication. send data through internet. I'll became a server and you can send me a data. from aan.redirectme.net. Thanks' anyway

  10. #10
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    990

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    CVMicheal if am writing a stand alone app (chat app) must i use a public host to portforward brfore i can connect to another computer in another network lan?

  11. #11
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Aan2702,CVMichael
    can you help me

  12. #12
    New Member
    Join Date
    Apr 2009
    Posts
    2

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    Hi I just want to ftp a file from my windows to linux machine. The linux machine ip is known. Its in the local area network. Please help

  13. #13
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    990

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    There is a bug in the implementation, if you try to connect more that one client, i get a "address in use" error?

    have any of you manage to resolve this
    Programming is all about good logic. Spend more time here


    (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  14. #14
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    this lan means everything on say a home or office network?
    and the adminstrater gets the client or the server?

  15. #15
    Addicted Member morkie's Avatar
    Join Date
    Jan 2009
    Location
    P4
    Posts
    202

    Re: VB6 - Winsock, Auto find server using UDP Broadcast (LAN ONLY)

    how can i display the list of connection in listbox...
    the list of servers they want to connect with them...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width