Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinSock Port Redirector

Status
Not open for further replies.

excalibur78

IS-IT--Management
Jan 3, 2001
66
US
I been trying for few days now to write a program that listens on a port and anything it hears is passed to a remote ip and port. Example: Listen on port 1000 on the local ip and anything it hears is redirected to remoteip on port 80. If anyone has any help it'd be great.

Thanks

Excalibur
 
This should do the trick for you...
Add two Winsock controls to a form, and set the protocol on both to UDP. (I'm assuming this is what you are using.)

<--- insert in Form_Load event --->

'Bind the first socket to the 'listening' port.
Winsock1.Bind 1000
'Set the remote host address to forward the data to.
Winsock2.RemoteHost = &quot;111.111.111.111&quot; 'use your address here.
'Binds the sending socket to a random available port.
Winsock2.Bind 0

<--- insert in Winsock1_DataArrival event --->

Dim strData$
Winsock1.GetData strData, vbString, BytesTotal
Winsock2.SendData vbString

 
Sorry.. forgot to set the remote port for Winsock2.. Form_Load event code should be as follows..

<--- insert in Form_Load event --->

'Bind the first socket to the 'listening' port.
Winsock1.Bind 1000
'Set the remote host address to forward the data to.
Winsock2.RemoteHost = &quot;111.111.111.111&quot; 'use your address here.

'Set the remote port to forward data to.
Winsock2.RemotePort=80

'Binds the sending socket to a random available port.
Winsock2.Bind 0

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top