Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:18:24+00:00 2026-06-03T16:18:24+00:00

I am looking to create a private torrent tracker but I have came across

  • 0

I am looking to create a private torrent tracker but I have came across a problem. I found in the protocol specifications that the compact response that the most clients use now is presented as binary 4 byte represendint the IP address in big-endian and 2 represent the port. I have attempted to do this but unsure of what format I should input the IP

I have attempted the following

$IP = "12.34.56.78";
$port = "12345";

$binary = pack("Nn", $IP, $port);

but when I attempt to convert this back using unpack(“Nn” $binary) I just get a return of the first part of the IP addrss in this example it would be “12” I attempt to try this with a torrent client I get “internal server error”

I have also tried ip2long and when I reverse that I get the long ip but when I am unsure if this is the correct format or what, all I know it is looking for ip and port in 6 bites.

any sugestions for where I am going wrong would be greatly appreciated

Vip32

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:18:26+00:00Added an answer on June 3, 2026 at 4:18 pm

    Try this:

    Packing:

    $ip = "12.34.56.78";
    $port = 12345;
    
    $packed = pack("Nn", ip2long($ip), $port);
    

    Unpacking:

    $unpacked = unpack("Nip/nport", $packed);
    
    echo "IP was ".long2ip($unpacked["ip"])."\n";
    echo "Port was ".$unpacked["port"]."\n";
    

    Output:

    IP was 12.34.56.78
    Port was 12345
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to create something that resembles a table in Tkinter but it
I am looking into TDD and I have come across a scenario that I
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create something like in this image. Each block would have an
I am looking to create a reg ex in JS that obtains 2 values
I'm looking to create a windows program that doesn't require any environmental dependencies (like
What I'm looking to do is create a custom controller list that displays a
I'm looking for a following pattern: I have several methods like this: 1. private
Is there a way to create private global variables in JavaScript? I have tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.