Forum > Networking and Web Programming
Accessing the MySQL database of the intranet host through libssh2
(1/1)
myisjwj:
I have connected to the remote external host using Libssh2, and now I want to map the port of the internal host to 127.0.0.1. The code is as follows:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- localPort := 33069; tunnelSock := fpSocket(AF_INET, SOCK_STREAM, 0); FillChar(tunnelAddr, SizeOf(tunnelAddr), 0); tunnelAddr.sin_family := AF_INET; tunnelAddr.sin_port := htons(localPort); tunnelAddr.sin_addr.S_addr := INADDR_ANY; rc := fpBind(tunnelSock, @tunnelAddr, SizeOf(tunnelAddr)); rc := fpListen(tunnelSock, 1); channel1:=libssh2_channel_direct_tcpip_ex(session1, '192.168.0.77', 3306, '127.0.0.1', localPort);
But now MySQL cannot connect to the intranet host. The error is: MySQL waiting for initial communication packet.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- rc := fpBind(tunnelSock, @tunnelAddr, SizeOf(tunnelAddr)); rc := fpListen(tunnelSock, 1); channel1:=libssh2_channel_direct_tcpip_ex(session1, '192.168.0.77', 3306, '127.0.0.1', localPort);
All return to normal.
Navigation
[0] Message Index