Giter VIP home page Giter VIP logo

Comments (6)

uNetworkingAB avatar uNetworkingAB commented on June 13, 2024

We don't provide any timeout. That timeout comes from the OS. You control the timeout in your OS, or use us_socket_timeout on the connecting socket.

from usockets.

federicorossi avatar federicorossi commented on June 13, 2024

Thank you. I think that to use us_socket_timeout the us_socket_context_connect has to finish first. The problem I am facing is to control the timeout for the connect. Do you know how to change the OS timeout?

from usockets.

uNetworkingAB avatar uNetworkingAB commented on June 13, 2024

You don't need to wait. us_socket_context_connect returns a us_socket_t and you can start a timeout directly when it returns. The only thing that can take time inside us_socket_context_connect is if you pass it some domain name that doesn't resolve immediately. But you can solve that by resolving the domain to an IP yourself, before you call us_socket_context_connect.

from usockets.

federicorossi avatar federicorossi commented on June 13, 2024

I am passing a local IP address and port that is not assigned to any device on purpose to try to limit the timeout and it takes 20s to return the socket. Is there a way to make the us_socket_context_connect to exit from another thread?

from usockets.

uNetworkingAB avatar uNetworkingAB commented on June 13, 2024

us_socket_context_connect calls some hostname resolving syscall that hangs until done. So you cannot abort it. Just make sure whatever you pass us_socket_context_connect actually resolves to something and it should return immediately. You can do this by resolving whatever you want to connect to before you pass it to us_socket_context_connect.

from usockets.

federicorossi avatar federicorossi commented on June 13, 2024

Thank you, I will do that.
As I am passing the IP address I think the hostname resolution could be bypassed.
If you could point out what function the hostname resolution I could locally patch it.
Perhaps it could be also addressed later as an improvement to the library.

from usockets.

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.