Questions tagged [nonblocking]

Non-blocking mode I/O either transfers at least one byte or returns immediately with an error or end of stream. Non-blocking algorithms refer to use of concurrency without the usual mutual exclusion primitives, guaranteeing that thread operations will not block indefinitely. This is usually handled with atomic value modification (increment/decrement) and/or reading (compare-and-exchange) operations.. It isn't clear which this tag is intended for.

Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

What exactly makes a non-blocking socket block? The possible danger of using epoll() in edge-triggered mode

Say we want to write a server to handle multiple clients by using epoll in edge-triggered mode. While using epoll() in edge-triggered mode, whenever the server receives the EPOLLOUT or EPOLLIN event, ...
Sgg8's user avatar
  • 199
0 votes
0 answers
35 views

epoll not receiving `EPOLLIN` signal when server sends data to tcp client

When I create a TCP client and connect it to a server, it is able to detect when it is connected (by virtue of EPOLLOUT). The server is supposed to send a message to the client, but the client never ...
Habib Ayode's user avatar
0 votes
2 answers
121 views

pure C++ design pattern non-blocking for loop

I tried to read about my problem but can't even find the right words to google it. Lets say I have a function like this in pure C++ (will run on an ESP32, no threads): void ...
muebau's user avatar
  • 152
2 votes
2 answers
73 views

Is my code thread-safe? [Java, CAS, money transfer]

I am solving classic java concurency kata: you have a bunch of accounts and you need to transfer money from one to another in multi-thread env. So I've learned and wrote all possible solutions with ...
Blednov Roman's user avatar
-1 votes
0 answers
16 views

Non-blocking connect of an UDP socket fails with EADDRNOTAVAIL?

On macOS and iOS, I want to connect a BSD socket to an remote address+port. The code won't know up front if that socket is a UDP or a TCP socket, so to prevent any issues with the connect() call ...
Mecki's user avatar
  • 127k
1 vote
1 answer
73 views

Suspend keyword as redundant with Network Request function in Spring Boot Application

I've been delving into Kotlin Coroutines and discovered that suspending functions can simplify the creation of asynchronous and non-blocking code when using Kotlin and Coroutines. In an Android ...
Drex's user avatar
  • 3,491
3 votes
1 answer
220 views

Virtual thread for reading InputStream from HTTP response

With the java 21 one can convert a blocking IO code to non-blocking one by just executing it in a virtual thread. Should I simply wrap the HTTP call that returns an InputStream (as in method ...
Urb's user avatar
  • 213
0 votes
1 answer
62 views

python request blocks publishing of mqtt messages

I am developing a program which get data from two sources: Incoming mqtt messages (paho) from a frontend and data from a RestAPI (request) The incoming mqtt messages triggers the request to the ...
nico's user avatar
  • 35
0 votes
0 answers
79 views

Spring reactive r2dbc - how to loop first query which returns Flux<String> and call second query which returns Flux<Object> in non blocking way?

I'm not sure if this is doable in reactive way. My first query returns Flux and I need to iterate it, to create a custom query which returns Flux and my method returns Flux<Flux> First Query var ...
Libin's user avatar
  • 135
0 votes
0 answers
28 views

serverSocketChannel.accept() returns null

I am trying to write a simple client server program in Java NIO. Here is the code: package org.lb; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey;...
Rahul's user avatar
  • 2,004
0 votes
0 answers
45 views

How to continue performing asynchronous actions after return in php?

I'm just a beginner, please tell me if it is possible to return the result from a php function, but at the same time so that asynchronous actions continue to work in it using the amphp library? ...
misksa's user avatar
  • 1
2 votes
2 answers
52 views

Interlocked Class: read before write race condition problem

using System; using System.Threading; using System.Threading.Tasks; namespace InterlockedLearning { class Program { static int sharedVariable = 0; static void Main() {...
user22422035's user avatar
0 votes
0 answers
40 views

non blocking send receive: code executes arbitrarily openmpi c++

I am using openMPI for building a code to solve Eulers equations. For this I need to send an array of properties (cols= conservative properties, rows= node nos.) across different processes. A snippet ...
shekhar's user avatar
  • 23
0 votes
0 answers
116 views

Golang Non Blocking os.Stdin Read for Cmd

cmd := exec.Command("env") cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout This works well regardless env command doesn't relay on reading from stdin Yet for cmd := exec.Command("env")...
404's user avatar
  • 227
0 votes
1 answer
90 views

Java NIO: How can I read into a buffer possibly multiple times?

I am working on a Java project. I have the following code that is part of the Selector's while loop. The response is supposed to be less than 256 and it ends with a line break. But as far as I ...
sleekster's user avatar
0 votes
1 answer
106 views

How to do non-blocking Read() for io.PipeRaeder in Golang

I have following code. The executable program will send some text to stdout after 5 seconds. So, in.ReadLine() will block until receive data. How can I set a timeout for ReadLine() or do it in a non-...
Josh Chiu's user avatar
  • 872
0 votes
0 answers
75 views

Cannot read data from SSL_read_ex with non-blocking socket

I'm having trouble using SSL_read_ex with non-blocking sockets, especially I'm having trouble when requesting an invalid resource from Google: https://www.google.com/<something invalid here>. ...
jdl's user avatar
  • 1
0 votes
1 answer
137 views

How to listen on a server-side websocket non-blocking in Go

I use https://pkg.go.dev/golang.org/x/net/websocket for creating a server-side websocket. All communication through it is in JSON. Thus, my code contains: func wsHandler(ws *websocket.Conn) { ...
Torsten Bronger's user avatar
0 votes
0 answers
65 views

poll returns zero even though there is data to be read in from the file descritors i specified

I've been working on making a simple HTTP server and I got stuck with this problem for almost a week with I run siege to test the server it runs perfectly for some time and then it blocks and when I ...
younes askour's user avatar
0 votes
4 answers
278 views

Webflux streaming DataBuffer with zip resulting in corrupt file

Currently I'm implementing a non blocking i/o application with Spring Boot 2.7.12 and Webflux to download files with a webclient, zip them and stream the zip file to the browser. Downloading and ...
Roberto's user avatar
1 vote
1 answer
180 views

epoll server with EPOLLET. When should I mark a socket with EPOLLOUT?

So been trying to make an asynchronous server with epoll (edge-triggered). Everything seems to work fine unless I send large files (30-33 MB) over the socket, which ofcourse gives EAGAIN with send ...
Cardinal's user avatar
1 vote
0 answers
81 views

How to make this pipe communication non-blocking?

I've created 2 small programs to test inter-program communication. It works as expected, but I want to make it non-blocking. Like it is now if either the server (main) program or the client is ...
IvanS's user avatar
  • 49
0 votes
1 answer
126 views

How to fix Error 141 when using select() and send() in C++ web server for multiple clients

I'm working on building a web server in C++ that needs to serve multiple clients simultaneously without blocking any individual client. To achieve this, I'm using the select() function. I'm ...
TouFa7's user avatar
  • 43
0 votes
1 answer
107 views

Why do I get an error when using epoll in edge triggered case inside the for loop?

So I have been trying to write a server that using epoll for non-blocking I/O using edge-triggered polling.So whenever I try to connect to the server using netcat, also passing the -c flag to close it ...
Cardinal's user avatar
0 votes
0 answers
18 views

FLash erase hang the other process in PIC32

I am using pIC32 mz series and trying to implement non blocking mode with interrupt and callback using flag. static volatile bool xfer_done = false; static void NVM_EventHandler(uintptr_t context) { ...
Piu's user avatar
  • 19
0 votes
1 answer
53 views

what is the difference between multi-thread blocking and non-blocking?

I am using libcurl to do url request, the network latency is not acceptable. so i want it to be non blocking. the bad news is libcurl non-blocking method is very confusing, my ideal api function will ...
nothingisme's user avatar
0 votes
1 answer
182 views

Implementing a waiting mechanism in an application similar to Omegle using LSH algorithm and Minhash [duplicate]

I'm developing an application similar to Omegle, where users are matched with strangers based on their common interests. To achieve this, I'm combining the LSH (Locality Sensitive Hashing) algorithm ...
Abhijith Ea's user avatar
1 vote
1 answer
394 views

Mono.just() is still blocking in my use case when the emitted element is pending

I have two test that use sleep() to simulate an api call which takes time to process, and test if Mono.just() make it non-blocking. In my first test, I emitted a String directly, but made it blocking ...
Rionash's user avatar
  • 29
0 votes
1 answer
42 views

What is blocking behaviour at EOF

Would it be possible that a read on a file descriptor (in this case a non-blocking socket) that has reached EOF would block before EOF can be detected? Like in the following sequence: read returns -1 ...
user877329's user avatar
  • 6,644
0 votes
0 answers
78 views

Can we do popen with non blocking fgets on pipe in Windows C++. Otherwise ca we use fcntl, select or poll API on File read

We implemented exec API with popen and fgets. As fgets is blocking API. The command executed through popen hangs or stuck, then main parent process gets blocked forever. To resolve this is there ...
Sushma Gane's user avatar
1 vote
1 answer
310 views

Implementing an lock-free unbounded queue with new atomic.Pointer types

I am trying to implement this non-blocking queue from Michael and Scott. I am trying to use the new atomic.Pointer types introduced in Go 1.19 but I am getting a data race in my application. Here is ...
Manuel Martinez's user avatar
0 votes
0 answers
11 views

Expres. JS Same client, Multiple Request, Blocking next one

Was facing this issue with php. If i try to make multiple request to express server which takes 3-5 seconds to run with same browser, It block next one. There is no problem when i try with incognito ...
Ali Haydar Güleç's user avatar
1 vote
0 answers
46 views

curiosity about how nodejs handles asynchronous tasks in nodejs

I'm new to nodejs, and I became curious about how nodejs handles asynchronous tasks in nodejs. After reading documents from nodejs docs, I found that nodejs chose event loop / non-blocking operation ...
dolbin-prime's user avatar
2 votes
1 answer
292 views

How to make non-blocking ReadLineAsync() to run concurrently in .NET?

How can we read file lines using non-blocking IO concurrently? A straightforward use of async await such that presented in BiggestLineSequential results in a sequential execution: static async Task<...
Diogo Rodrigues's user avatar
0 votes
1 answer
81 views

Using most significant bits of pointers as a tag in non-blocking queue c++

I am trying to implement a concurrent non-blocking queue where the tag is in the 16 most significant bits of the pointer. It follows this algorithm here: http://www.cs.rochester.edu/research/...
callum arul's user avatar
0 votes
1 answer
489 views

Python socket non-blocking recv() exception(s) and sendall() exception

I'm writing a simple TCP relay server, which is gonna be deployed both on a Windows and a Linux machine (same code base). Naturally there're gonna be two sockets to work with. I would like to know ...
chakmeshma's user avatar
1 vote
1 answer
171 views

Multithreading for CPU Intensive VS Promises for CPU Intensive? Under the hood, Would they be the same?

let's say we have a very CPU intensive code in NodeJs: for (var i = 0; i < 1e10; i++){} I've heard that under the hood nodejs uses pool threads for handling asynchronous code. So my question is: ...
Guilherme Gavioli's user avatar
0 votes
1 answer
323 views

Redis scan issue for multiple replica configuration

I am using AWS Elasticache redis(cluster mode off) with 1 primary and 2 replica and trying to get keys from redis for a given key pattern using redis scan command (scan (cursor, count, matchGlobe)) ...
Shashi's user avatar
  • 33
0 votes
0 answers
38 views

non-blocking forwarding of inbound HTTP request body to outbound HTTP request body with Java

I am looking for a succinct code example that demonstrates non-blocking 'piping' the body of an incoming HTTP POST request to the body of an outgoing HTTP POST request in Java. There are certainly ...
MarkE's user avatar
  • 140
0 votes
0 answers
29 views

How to call plenty of hierarchical RESTful APIs simultaneously and efficiently in Java

Suppose I've got a RESTful API /getDivision/dID=?, the ? need to be replaced with the actual division ID. Assuming the dID=1, it return a JSON like below: { "division": 1 "...
Andrew Law's user avatar
5 votes
1 answer
129 views

How to "mark" pointers by setting the last bit to 1?

I am trying to mark and unmark pointers so I can implement Non-Blocking linked lists. I checked that on my architecture the last bit is never used, so I am trying to use change it to mark/unmark ...
Andrejcc's user avatar
  • 144
0 votes
2 answers
206 views

detecting connection state in epoll linux

There are many threads regarding how to detect if a socket is connected or not using various methods like getpeername / getsockopt w/ SO_ERROR. https://man7.org/linux/man-pages/man2/getpeername.2.html ...
Noah Barcomb's user avatar
2 votes
0 answers
66 views

Is JMC's "Java Monitor Blocked" caused by vert.x Http1xServerConnection problem?

I do profile my vert.x based http service and noticed in JMC that all my envelop threads(aka verticles) produce lots of "Java Monitor Blocked" events in class io.vertx.core.http.impl....
slesh's user avatar
  • 1,922
0 votes
1 answer
38 views

How to get IO errors in `O_NONBLOCK`ed code?

Once I have enabled O_NONBLOCK, and then call a non-blocking function, and after it returns some I/O error happens, how may I get to know that something bad has happened, and how to handle it?
gitman-2021's user avatar
2 votes
0 answers
147 views

Using Java Cipher in non-blocking environment

We have a multi-threaded environment wherein we perform encryption and decryption using javax.crypto.Cipher class. However, we are facing a Cipher blocking issue. The thread dumps indicate the ...
Shadi Alian's user avatar
0 votes
0 answers
70 views

Non-blocking Python window only displaying a constantly updating image

I want to develop an application that uses multiple threads to read user input from the keyboard and translate that to an image on the screen, very quickly so that it can be updated quickly enough ...
Lawrence's user avatar
0 votes
1 answer
250 views

UDP client socket read less data then sent

I am facing a very strange problem. I have a server application that runs UDP socket and wait for incoming data. As soon as it gets the command it begins to send back a stream. Just for testing, I ...
folibis's user avatar
  • 12.2k
0 votes
1 answer
174 views

Java NIO non-blocking read and write operations

I'm developing for a project a NIO server that takes as input a message from the client containing the times of running for the read and write operations. I have a problem because at the first ...
Luca's user avatar
  • 105
0 votes
0 answers
20 views

best way to serve local file via express.js server

Our server serves single json file which has 1GB size. When request incomes, server reads that file and if certain element is included(matched) then we server that file, but if not, just throws an ...
user14082's user avatar
  • 350
0 votes
2 answers
703 views

Non-blocking vs blocking Java server with JDBC calls

Our gRPC need to handle 1000 QPS and each request requires a list of sequential operations to happen, including one which is to read data from the DB using JDBC. Handling a single request takes at ...
HLP's user avatar
  • 2,162

1
2 3 4 5
32