Elementary Proxy on Visual Basic |
![]() |
Free VB eBook - The most elementary single-thread Proxy in Visual Basic. In creating this manual we set ourselves the task to develop a minimum program code playing the role of Proxy-server (transmitting information from one port to another). It is easy to add filtration functions to the program (it will be shown in the supplement), log records, information substitution records (link addresses, advertisement in HTML - for web site promotion).
|
End Sub Line “ToServer = ServerData” - is not mandatory, it is worthwhile, if it is necessary to process data writing in the log, filter, search for data in queries, substitute information (for example, change URL in downloaded web-pages for one’s own) etc. The entire VB project of this development stage is in the file vbpt1.zip Write the Client part of Proxy For work with real Web-server. Connection to Web-server, sending of queries and data receipt. Announce the variables Dim Webport ''Port number Dim Data As String ''To receive data from Web-server Private Sub Oflameron_SendToWebserver() ''Connect to Web-server Oflameron.Close ''Close the connection Oflameron.RemoteHost = "10.62.182.54" ''Web-server address or its IP address Oflameron.RemotePort = 80 ''Port number. Standard for HTTP Oflameron.Connect ''Connect to Web-server Webport = Oflameron.RemotePort ''Remember the port number (optional line) End Sub Procedure Oflameron_Connect performs actions as soon as the Web-server is connected Private Sub Oflameron_Connect() ''Sent query to Web-server If Oflameron.State <> sckConnected Then Exit Sub ''Check. If there is no connection, abandon the procedure Oflameron.SendData ToServer ''Send the query line to the Web-server End Sub The procedure of data receipt from the Web-server Private Sub Oflameron_DataArrival(ByVal bytesTotal As Long) ''The call will be initiated as soon as some data is received from the Web-server Text1.Text = Oflameron.State If Oflameron.State <> sckClosing Then Oflameron.GetData Data ''It will contain data obtained from the Web-server Winsock1.SendData Data ''Send the obtained data from Web server to Web-browser End If End Sub |
|