|
-
Aug 17th, 2006, 04:23 AM
#1
Thread Starter
Addicted Member
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:
Option Explicit
Private Sub Form_Load()
Winsock1.LocalPort = 50
Winsock1.RemotePort = 90
Winsock1.RemoteHost = "192.168.1.1"
Winsock1.Protocol = sckUDPProtocol
Winsock1.Bind Winsock1.LocalPort
End Sub
Private Sub Text1_Change()
Winsock1.SendData Text1.Text
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim m_data As String
Winsock1.GetData m_data
Label1.Caption = m_data
End Sub
Client Code:
VB Code:
Option Explicit
Private Sub Form_Load()
Winsock1.LocalPort = 90
Winsock1.RemotePort = 50
Winsock1.RemoteHost = "192.168.1.1"
Winsock1.Protocol = sckUDPProtocol
Winsock1.Bind Winsock1.LocalPort
End Sub
Private Sub Text1_Change()
Winsock1.SendData Text1.Text
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim m_data As String
Winsock1.GetData m_data
Label1.Caption = m_data
End Sub
Thanks
arunb
-
Aug 17th, 2006, 04:35 AM
#2
Retired VBF Adm1nistrator
Re: Help with port forwarding in winsock
To be honest I don't actually know what you're trying to do... Can you elaborate?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 17th, 2006, 05:15 AM
#3
Thread Starter
Addicted Member
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
-
Aug 17th, 2006, 05:40 AM
#4
Retired VBF Adm1nistrator
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.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 17th, 2006, 05:58 AM
#5
Thread Starter
Addicted Member
Re: Help with port forwarding in winsock
So how do I do connect using winsock ???
thanks
-
Aug 17th, 2006, 02:49 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|