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 8332035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:36:07+00:00 2026-06-09T02:36:07+00:00

I am attempting to create a torrent scraper in objective-c, I am using CocoaAsyncSocket

  • 0

I am attempting to create a torrent scraper in objective-c, I am using CocoaAsyncSocket to send the data packets over UDP. Following the BitTorrent UDP Tracker Protocol. I have verified using Wireshark that packets have been sent, but the tracker does not send anything back. I am assuming I am doing something wrong in putting together the data that is sent, since I have very little experience with data manipulation. Right now I am just trying to successfully complete the connect request of the protocol. Here is the code

-(void)connect {

     NSString *host = @"tracker.publicbt.com";
     GCDAsyncUdpSocket *socket = [[GCDAsyncUdpSocket alloc]initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
     [socket connectToHost:host onPort:80 error:nil];


}

-(void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address {
    uint64_t connection_id = htonl(0x41727101980);
    uint32_t action = htonl(0);
    uint32_t transaction_id = htonl(122);
    NSMutableData *data = [NSMutableData data];
    [data appendBytes:&connection_id length:sizeof(connection_id)];
    [data appendBytes:&action length:sizeof(action)];
    [data appendBytes:&transaction_id length:sizeof(transaction_id)];
    [sock sendData:data toAddress:address withTimeout:-1 tag:1];

}
  • 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-09T02:36:08+00:00Added an answer on June 9, 2026 at 2:36 am

    Now I think I know the problem.

    Since the connection ID must be initialized to that exact value, you need to make sure that it is intact. You are making a mistake in that htonl() returns a uint32_t, which is not going to be what you want. You need to break the connection id into 2 parts and independently convert them to network byte order.

    uint64_t wholeConnectionID = 0x41727101980LLU;
    
    uint32_t connectionID[2];
    connectionID[0] = htonl(wholeConnectionID >> 32);
    connectionID[1] = htonl(wholeConnectionID & 0xffffffff);
    
    // ...
    
    [data appendBytes:connectionID length:sizeof(connectionID)];
    

    If this doesn’t solve your problem, it will at least be a required step to get to that point anyways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I attempting to create custom tabs using this . But when I try to
I'm attempting to Create a Job and Add a Batch using the Salesforce Bulk
I am attempting to create the following class name signature: public class MyClass<T> where
I'm attempting to create a linked list of length n using Python. I have
I am attempting to create an Excel spreadsheet in C#. I am using VSE
I am attempting to create a very basic login screen, using the Storyboard designer
I'm attempting to create a report for an accommodation service with the following information:
I'm attempting to create a custom control that inherits from System.Web.UI.WebControls.ListView . Codebehind: using
I'm attempting to create an app to pull the sqlite data from a preexisting

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.