Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: URL-Binary Number  (Read 8362 times)

0 Members and 1 Guest are viewing this topic.

justravee

    Topic Starter


    Newbie

    URL-Binary Number
    « on: November 29, 2009, 08:40:26 AM »
    How do i convert a URL into a binary number which will enable me to access that website?

    I know that by pinging a particular website we get the IP address of same but don't know from then on how to proceed ahead.

    When i ping a site i get a request time out reply ie. zero packet received.

    Salmon Trout

    • Guest
    Re: URL-Binary Number
    « Reply #1 on: November 29, 2009, 09:06:27 AM »
    Do you mean you want to convert a text url like this

    www.computerhope.com

    into an ip address like this

    81.200.64.50

    ?

    Firstly the ip address is not a "binary number". It is four decimal numbers separated by dots, a so-called "dotted quad".

    batch code

    getIP.bat

    Code: [Select]
    @echo off
    for /f "tokens=1-26 delims=[]" %%A in ( ' ping %1' ^| find "Pinging" ' ) do set IPaddress=%%B
    echo IP address is %IPaddress%

    use like this

    Code: [Select]
    C:\>getIP.bat www.computerhope.com
    IP address is 81.200.64.50

    « Last Edit: November 29, 2009, 12:32:46 PM by Salmon Trout »

    justravee

      Topic Starter


      Newbie

      Re: URL-Binary Number
      « Reply #2 on: November 29, 2009, 09:48:11 AM »
      How can we access a website by a binary no. ?

      what u need to do is convert the ip decimal (either the first two nos. or last two separated by decimal) into binary no. and then paste the binary no. to the address n access .....i mean this is what i did 5 years back...but i dont remember now......

      This is useful when u wanna access any site under the sun.....

      If u know let me know

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: URL-Binary Number
      « Reply #3 on: November 29, 2009, 09:50:27 AM »
      Did you read the Post above ? ?
      " Anyone who goes to a psychiatrist should have his head examined. "

      Salmon Trout

      • Guest
      Re: URL-Binary Number
      « Reply #4 on: November 29, 2009, 12:32:01 PM »
      Did you read the Post above ? ?

      I very much doubt it, but if he wants binary I'll damned well give him binary!

      Getip2.bat

      Code: [Select]
      @echo off
      setlocal enabledelayedexpansion
      set binIP=
      for /f "tokens=1-2 delims=[]" %%A in ( ' ping %1' ^| find "Pinging" ' ) do set IPaddress=%%B
      for /f "tokens=1-4 delims=." %%B in ("%IPaddress%") do (
          call :decbin %%B
          set binIP=!bstring!
          call :decbin %%C
          set binIP=!binIP!.!bstring!
          call :decbin %%D
          set binIP=!binIP!.!bstring!
          call :decbin %%E
          set binIP=!binIP!.!bstring!
          )

      goto end
         
      :decbin
        set bstring=
        SET /A a=%1
        SET /A b= (%a% "&" 128)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 64)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 32)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 16)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 8)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 4)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 2)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
        SET /A b= (%a% "&" 1)
        if %b% EQU 0 (set bstring=%bstring%0) else set bstring=%bstring%1
       
        goto :eof
             
      :end
      echo Decimal IP address is %IPaddress%
      echo  Binary IP address is %BinIP%

      Code: [Select]
      C:\>getip2 www.computerhope.com
      Decimal IP address is 81.200.64.50
       Binary IP address is 01010001.11001000.01000000.00110010

      justravee, type that binary IP address into your browser and tell us what happens...





      Salmon Trout

      • Guest
      Re: URL-Binary Number
      « Reply #5 on: November 29, 2009, 12:49:13 PM »
      Quote
      this is what i did 5 years back...but i dont remember now

      Don't you just love this type of question?

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: URL-Binary Number
      « Reply #6 on: November 29, 2009, 06:24:49 PM »
      I for one can't fathom the dilemna...
      I thought your answers solved the issue...

      Perhaps i'm wrong but it works  on my end...
      " Anyone who goes to a psychiatrist should have his head examined. "

      soybean



        Genius
      • The first soybean ever to learn the computer.
      • Thanked: 469
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 10
      Re: URL-Binary Number
      « Reply #7 on: November 29, 2009, 07:19:17 PM »
      Uh ..., is binary really supposed to work?  I get: Firefox can't find the server at 01010001.11001000.01000000.00110010

      Salmon Trout

      • Guest
      Re: URL-Binary Number
      « Reply #8 on: November 30, 2009, 12:13:55 AM »
      Uh ..., is binary really supposed to work?  I get: Firefox can't find the server at 01010001.11001000.01000000.00110010

      shhhh! Don't spoil the surprise!


      Salmon Trout

      • Guest
      Re: URL-Binary Number
      « Reply #9 on: November 30, 2009, 02:24:25 AM »
      More compact decimal to binary conversion

      Code: [Select]
      @echo off
      setlocal enabledelayedexpansion
      set binIP=
      for /f "tokens=1-2 delims=[]" %%A in ( ' ping %1' ^| find "Pinging" ' ) do set IPaddress=%%B
      for /f "tokens=1-4 delims=." %%B in ("%IPaddress%") do (
          call :decbin %%B
          set binIP=!bstring!
          call :decbin %%C
          set binIP=!binIP!.!bstring!
          call :decbin %%D
          set binIP=!binIP!.!bstring!
          call :decbin %%E
          set binIP=!binIP!.!bstring!
          )

      goto end

      :decbin
      set /a a=%1
      set bstring=
      FOR %%V IN (128 64 32 16 8 4 2 1) do (
            SET /A b=%a% "&" %%V
            if !b! EQU 0 (set bstring=!bstring!0) else (set bstring=!bstring!1)
          )
      goto :eof
             
      :end
      echo Decimal IP address is %IPaddress%
      echo  Binary IP address is %BinIP%

         

      gh0std0g74



        Apprentice

        Thanked: 37
        Re: URL-Binary Number
        « Reply #10 on: November 30, 2009, 03:04:58 AM »
        a normal person doing normal routine task doesn't need to input binary numbers to url to surf a site. I can't think of a reason one wants to do this, except, 1) its homework, 2) you are trying to bypass the security system.

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: URL-Binary Number
        « Reply #11 on: November 30, 2009, 03:11:22 AM »
        I believe the entire point Salmon trout is making is that they are NOT binary numbers, they are Decimal- that is, base-10, numbers.
        I was trying to dereference Null Pointers before it was cool.

        Salmon Trout

        • Guest
        Re: URL-Binary Number
        « Reply #12 on: November 30, 2009, 03:19:59 AM »
        I believe the entire point Salmon trout is making is that they are NOT binary numbers, they are Decimal- that is, base-10, numbers.

        At last!


        Salmon Trout

        • Guest
        Re: URL-Binary Number
        « Reply #13 on: November 30, 2009, 03:27:23 AM »
        a normal person doing normal routine task doesn't need to input binary numbers to url to surf a site. I can't think of a reason one wants to do this, except, 1) its homework, 2) you are trying to bypass the security system.

        You can't surf to a website by entering an ip address as a sequence of binary strings separated by dots. It doesn't work. The OP asked about converting a url into a "binary" number and was told that dotted quads use decimal numbers. He ignored this, asking more or less the same question again. Out of whimsy I concocted a script to translate a web address into binary strings as well as decimal, to prove that it doesn't work.

        The only reason I can think for wanting IP addresses for websites is to bypass DNS or HOSTS restrictions on surfing, also as you say, homework.