Converting those last two numbers to port and vice versa is easy

eg, ",7,208" becomes 2000, and 2000 becomes ",7,208"
Here's some VB source, sorry i dont have the time to convert it to PB but it's pretty straight forward!
Sorry im 9 months late too!

ive left my commenting in, hope it makes sense
Code:
Private Sub Form_Load() On Error Resume Next 'If you want the FTP server to connect to you on port 2000, 'you can find out the last two values of the PORT command 'by using PortString(tcpPort) Dim PortStr As String PortStr = PortString(2000) '= 7,208 MsgBox "2000=" & PortStr 'If you want to resolve "7,208" back to 2000, use this: Dim PortStr2 As Integer PortStr2 = PortResolve("7", "208") '= 2000 MsgBox "7,208=" & CStr(PortStr2) End Sub Public Function Dec2Bin(ByVal nDec As Integer) As String On Error Resume Next Dim i As Integer Dim j As Integer Dim sHex As String Const HexChar As String = "0123456789ABCDEF" sHex = Hex(nDec) 'That the only part that is different For i = 1 To Len(sHex) nDec = InStr(1, HexChar, Mid(sHex, i, 1)) - 1 For j = 3 To 0 Step -1 Dec2Bin = Dec2Bin & nDec \ 2 ^ j nDec = nDec Mod 2 ^ j Next j Next i 'Dec2Bin = Right("00000000" & Dec2Bin, 8) End Function Function Bin2Dec(bite) As Integer On Error Resume Next Y = Len(bite) - 1 For x = 1 To Len(bite) conv_bin_dec = conv_bin_dec + ((2 ^ Y)) * (Mid$(bite, x, 1)) Y = Y - 1 Next x Bin2Dec = conv_bin_dec End Function Public Function PortString(tcpPort As Integer) As String On Error Resume Next CZ = Dec2Bin(tcpPort) FZ1 = Left(CZ, 4) FZ2 = Right(CZ, Len(CZ) - 4) PortString = Trim(CStr(Bin2Dec(FZ1))) & "," & Trim(CStr(Bin2Dec(FZ2))) End Function Public Function PortResolve(p1 As String, p2 As String) As Integer On Error Resume Next CZ = Dec2Bin(Val(p1)) & Dec2Bin(Val(p2)) PortResolve = Bin2Dec(CZ) End Function
------------------
[This message has been edited by Wayne Diamond (edited November 07, 2000).]
Leave a comment: