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

  • Home
  • SEARCH
  • 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 7521421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:13:57+00:00 2026-05-30T02:13:57+00:00

I have a binary program developed for Linux which reads lines from a server’s

  • 0

I have a binary program developed for Linux which reads lines from a server’s network stream. Its communication is encrypted in a way that would take me too long to figure out, so I can’t rewrite it.

After outputting each line, the program calls nanosleep(100000000) (I found this using strace) However, when the server sends multiple lines in quick succession, there’s a big delay between the actual stream and the output.

Since I don’t have the source code of the program, my question: is there a way to reduce the sleep time of this software? “Accelerating” it?

For reference, the program is Punkbuster’s PBUcon

  • 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-05-30T02:13:57+00:00Added an answer on May 30, 2026 at 2:13 am

    You can try the LD_PRELOAD trick:

    /* nosleep.c */
    #include <time.h>
    #include <unistd.h>
    
    int sleep(unsigned int seconds)
    {
        return 0;
    }
    int usleep(useconds_t usec)
    {
        return 0;
    }
    int nanosleep(const struct timespec *req, struct timespec *rem)
    {
        return 0;
    }
    

    Then compile with:

    $ gcc -o libnosleep.so -shared nosleep.c -fpic
    

    And then run your program with:

    $ LD_PRELOAD=./libnosleep.so pbucon
    

    There are a few things you should be aware of:

    1. It will replace every call to nanosleep, not only the ones you don’t like, and that can have subtle undesired effects. You could check for the particular values of the argument, if you feel you need it.
    2. It will not work for suid/sgid programs.
    3. It will work only for dynamic-linked programs, Not for statically linked ones.

    UPDATE: If you want to chain the call to the original function, you can do the following:

    #define _GNU_SOURCE 
    
    #include <stdio.h>
    #include <unistd.h>
    #include <dlfcn.h>
    
    int usleep(useconds_t sec)
    {
        typedef int (*usleep_f)(useconds_t);
        static usleep_f real_usleep = NULL;
        if (!real_usleep)
            real_usleep = (usleep_f)dlsym(RTLD_NEXT, "usleep");
    
        printf("%d\n", (int)sec);
    
        if (...)
            return real_usleep(sec);
        else
            return 0;
    }
    

    If you wanted to avoid GNU extensions (RTLD_NEXT is one) you would have to discover the name of the shared library that contains the function, with for example:

    $ objdump -p pbucon.run | grep NEEDED
    NEEDED           libc.so.6
    

    And then, in the function do:

        if (!real_usleep)
        {
            void *libc_so = dopen("libc.so.6", RTLD_GLOBAL);
            real_usleep = (usleep_f)dlsym(libc_so, "usleep");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that downloads a binary file, from another PC. I also
I have a server program running a java binary code (xx.jar file). While it
I have a program which statically links to another library in linux using -L(mylib.a)
I have to code a Java program that will receive messages from network and
I have a C++ program that will read in data from a binary file
I have a binary of a program that waits for an input using scanf.
I have a binary search loop which gets hit many times in the execution
I have a binary image (a dll) which I wish to view the assembly
I have a program that opens a large binary file, appends a small amount
I have a program that convert image file to binary and also it converts

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.