Coder Social home page Coder Social logo

Comments (4)

richardtaylorrt avatar richardtaylorrt commented on June 27, 2024

Hi - fcntl() is not present in the Azure Sphere SDK. The SDK only includes APIs that Microsoft can presently support and maintain binary compatibility of across OS updates, and for the supported lifetimes of those devices. The SDK intentionally excludes some standard POSIX APIs and Linux syscalls that do not presently meet these criteria, even if they are physically present within the kernel or OS.

Instead, to get a non-blocking socket, it may help to look is this file in one of our samples.

Specifically, the sending socket is opened as non-blocking:

int sockType = SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK;
serverState->listenFd = OpenIpV4Socket(ipAddr, port, sockType);

from azure-sphere-samples.

fmuntean avatar fmuntean commented on June 27, 2024

That example is for getting a non-blocking socket bind to the local server port. I need to get a socket for client connection so don't need to bind(..) but connect(..) and tried already to change the bind to connect in the OpenIpV4Socket and is not working.

If there are some things intentionally excluded they should be documented as standard Linux api is to use the fcntl to make a non-blocking socket.

I still need an example code that works to create a client non-blocking socket for communication with another server.

from azure-sphere-samples.

richardtaylorrt avatar richardtaylorrt commented on June 27, 2024

Hi - that's interesting. Our dev teamm would expect this to be enough:

fd = socket(...,  <other options> | SOCK_NONBLOCK, ...);
connect(fd, ...);

In what way is this not working?

The dev team also advise that the connection may be async: i.e., connect() will return immediately. So you then have to wait (epoll/select/etc) on the socket fd and then when signalled check getsockopt() to see if the socket is writeable.

If this doesn't help, please share an example of the failing code. Thanks.

from azure-sphere-samples.

fmuntean avatar fmuntean commented on June 27, 2024

Thanks,
Tried it again and now is working as you explained above.

from azure-sphere-samples.

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.