Giter VIP home page Giter VIP logo

Comments (7)

agronholm avatar agronholm commented on May 19, 2024 1

Fixed in b383275.

from anyio.

agronholm avatar agronholm commented on May 19, 2024

Are you intent on disabling TCP_NODELAY for your sockets?

from anyio.

standy66 avatar standy66 commented on May 19, 2024

I want to be able to execute code similar to the following:

socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
if hasattr(socket, "TCP_KEEPIDLE"):
    socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 300)
elif is_darwin():
    # Darwin specific option
    # Value extracted from XNU source code
    # https://github.com/apple/darwin-xnu/blob/a449c6a3b8014d9406c2ddbdc81795da24aa7443/bsd/netinet/tcp.h#L207
    TCP_KEEPALIVE = 16
    socket.setsockopt(socket.IPPROTO_TCP, TCP_KEEPALIVE, 300)
socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 30)
socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 5)
socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

from anyio.

agronholm avatar agronholm commented on May 19, 2024

Yes, I get the use case for setsockopt(). I was merely wondering whether or not you knew that TCP_NODELAY is set for socket streams by default on anyio.

from anyio.

agronholm avatar agronholm commented on May 19, 2024

I implemented getsockopt() and setsockopt() in SocketStream but now I keep wondering if I should expose the raw socket instead. After all, the socket object has a huge amount of low level functionality but I'm uncertain whether it should be exposed or not.

from anyio.

standy66 avatar standy66 commented on May 19, 2024

Did you test it?
I'm getting TypeError: setsockopt() takes exactly 3 arguments (4 given) when calling socket_stream.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

socket.SocketType.setsockopt is a weird built-in method, it does not seem to work when you manually pass optlen=None

from anyio.

agronholm avatar agronholm commented on May 19, 2024

It seems that I only tested getsockopt() but forgot about setsockopt(). I will fix this tomorrow.

from anyio.

Related Issues (20)

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.