How does 192,168,1,2,7,138 convert to port 1930 on IP address

How do i deduce the port and ip from a number that FTP throws? For example 192,168,1,2,7,138 converts to 1930 on IP address

What is the logic behind?


The first four numbers indicate client IP, the second two numbers indicate the client port number. It's a hex to dec conversion.

16^2 * 7 + 138 = 1930

The first number stands for 3-rd and 4-th bit of a hex number (port number), the second is for 1-st and 2-nd bit of a hex number. So we have

7 = 07 in hex


138 = 8A in hex

Altogether we have

078A in hex which is 1930

or you can just skip that and convert only the first number to dec which is for 3-d and 4-th bit because of that "shift". The second number is already converted.

Need Your Help

How to match a logger on a specific sub package name?

django logging

In my Django project, I have several apps (say app_a, app_b, app_c). Each of these apps contains several commands:

Selenium locator for <label for=“x”>

testing selenium watin selenium-rc web-testing

With ASP.NET the tag IDs are pretty volatile so to make my tests more robust I want to locate elements by their label texts. I have played some with WatiN and it does this perfectly but that projec...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.