Coder Social home page Coder Social logo

libnodelay's Introduction

libnodelay

A small wrapper library to force TCP_NODELAY on all new sockets. It is intended for use with LD_PRELOAD on Linux and wraps the socket and setsockopt calls to enforce TCP_NODELAY being set for all TCP sockets.

Compiling

To compile libnodelay simply run make inside the repository. This will build libnodelay.so for your host system.

Additionally the make targets 32 and 64 are available to specifically build the library for either 32bit or 64bit. The binary file in this case will be either libnodelay32.so or libnodelay64.so depending on the chosen target.

Usage

To use libnodelay add it to the LD_PRELOAD environment variable. The suggested way is to simply export it and run your application afterwards.

export LD_PRELOAD=/path/to/libnodelay/libnodelay.so
./application

You may also add the 32bit and 64bit library in parallel which comes in handy when dealing with a mix of 32bit and 64bit executables such as when using wine.

export LD_PRELOAD=/path/to/libnodelay/libnodelay32.so:/path/to/libnodelay/libnodelay64.so
./application

In this case you may see errors such as the following. These can be safely ignored and are merely an information that for example the 32bit library could not be used for an 64bit application. However in that case the 64bit library will have been loaded instead.

ERROR: ld.so: object '/path/to/libnodelay/libnodelay64.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
ERROR: ld.so: object '/path/to/libnodelay/libnodelay32.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.

Testing

A small test executable is provided and can be compiled with make test. When run this executable will print whether TCP_NODELAY is set or not after creating a TCP socket.

Example:

./test
TCP_NODELAY is NOT set.

LD_PRELOAD=./libnodelay.so ./test
TCP_NODELAY is set.

Contributing

You are welcome to contribute to this project, simply open a pull request with your changes and they will be considered.

License

This project is licensed under the GPL-3.0-or-later License, see the COPYING file for details

libnodelay's People

Contributors

sschroe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

libnodelay's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.