PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Help with port forwarding in winsock-VBForums
Results 1 to 6 of 6

Thread: Help with port forwarding in winsock

  1. #1

    Thread Starter
    Addicted Member arunb's Avatar
    Join Date
    Jul 2005
    Posts
    131

    Help with port forwarding in winsock

    Hi,

    I changed the port forward settings to the folowing in my broadband router.
    Here are the entries.

    Name: CCL
    Trigger Port: 50 - 50
    Public Port: 90
    Trigger Type: UDP
    Public Type: UDP

    I have also made a server and client application that uses winsock control, these applications communicate well with the 127.0.0.1 address.

    I then changed the IP address to 192.168.1.1 (the ip address to my router-LAN address, the LAN address on my PC is through DHCP).

    When I run the application I find that an error 'Run Time error 10054, the connection is reset by remote side' occurs.

    Kindly advise how I can correct this I would like my server/client to run in an router environment.

    Server Code:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  
    5. Winsock1.LocalPort = 50
    6. Winsock1.RemotePort = 90
    7. Winsock1.RemoteHost = "192.168.1.1"
    8. Winsock1.Protocol = sckUDPProtocol
    9.  
    10. Winsock1.Bind Winsock1.LocalPort
    11.  
    12. End Sub
    13.  
    14. Private Sub Text1_Change()
    15.  
    16. Winsock1.SendData Text1.Text
    17.  
    18. End Sub
    19.  
    20.  
    21. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    22.  
    23. Dim m_data As String
    24.  
    25. Winsock1.GetData m_data
    26.  
    27. Label1.Caption = m_data
    28. End Sub

    Client Code:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  
    5. Winsock1.LocalPort = 90
    6. Winsock1.RemotePort = 50
    7. Winsock1.RemoteHost = "192.168.1.1"
    8. Winsock1.Protocol = sckUDPProtocol
    9.  
    10. Winsock1.Bind Winsock1.LocalPort
    11.  
    12. End Sub
    13.  
    14. Private Sub Text1_Change()
    15. Winsock1.SendData Text1.Text
    16.  
    17. End Sub
    18.  
    19. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    20.  
    21. Dim m_data As String
    22.  
    23. Winsock1.GetData m_data
    24.  
    25. Label1.Caption = m_data
    26.  
    27. End Sub



    Thanks
    arunb

  2. #2
    Banned plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Help with port forwarding in winsock

    To be honest I don't actually know what you're trying to do... Can you elaborate?

  3. #3

    Thread Starter
    Addicted Member arunb's Avatar
    Join Date
    Jul 2005
    Posts
    131

    Re: Help with port forwarding in winsock

    Sorry, I am trying to use the winsock control to send/receive data from the internet . The internet connection is done through a broadband router. The applications (code for which is posted above) are used for sending and receiving data.

    I was advised to use port forwarding for doing this..The router settings are also given.

    thanks
    arun

  4. #4
    Banned plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Help with port forwarding in winsock

    So someone will connect from the outside world directly into your computer?
    If your computer is establishing the connection out from your computer to another host on the internet then you don't need to use port forwarding - even for the inbound data on that connection.

  5. #5

    Thread Starter
    Addicted Member arunb's Avatar
    Join Date
    Jul 2005
    Posts
    131

    Re: Help with port forwarding in winsock

    So how do I do connect using winsock ???
    thanks

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Help with port forwarding in winsock

    Winsock works the same, whether you're port forwarding or not.

    Your problem is that you set up port triggering, not port forwarding - they're not the same thing. Set the computer the Winsock program will be running on to have a static internal IP that's outside the range of the DHCP server in the router. IOW, if the DHCP server leases .100 to .254, use an IP in the range of .2 to .99. (If the DHCP server leases .2 to .254, you're going to have to change that range in the router, because all addresses except the gateway are leased.)

    Note: Some routers will forward to leased addresses, others won't. ALL routers will forward to static (non-leased) addresses, so it doesn't hurt to just set a static address, unless you know that your router will forward to a leased address. (Which will cause you problems if you ever boot the computers on the LAN in a different order - the one needing forwarding will have the wrong address.)

    Now just forward whatever port(s) you're using to that address. (Use Both [TCP and UDP] unless you know which type of traffic you're looking for). This is for incoming connections - connections that your program initiates will work whether you have ports forwarded or not. (Port 80 is blocked, yet your web browser works just fine initiating connections on port 80.)

    Connections from outside your router are made to your external address - the one you see when you connect to http://www.whatsmyip.org/. Connections from inside the LAN are made to your 192.168.1.<whatever> address. Some routers will loop back - do an internal connection if the address you're going to is the router's external address - some won't know how to handle the request and you'll never connect, so use the internal address from inside.
    Last edited by Al42; Aug 17th, 2006 at 02:55 PM.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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