nonblocking

Confused about OpenSSL non-blocking I/O

我怕爱的太早我们不能终老 提交于 2019-11-30 03:58:17
In general, the OpenSSL library (C API) seems to offer two ways to do everything: you can either use plain system sockets configured to your liking, or you can use OpenSSL BIO objects which are sort of like streams. However, I'm often confused by some of the duplicated functionality. For example, how do you make an SSL connection non-blocking? One way seems to be to simply access the underlying file descriptor and set it to non-blocking using fcntl . But there is also an OpenSSL API function called BIO_set_nbio which takes in a BIO* object and sets it to non-blocking mode. So what is the best

Is Tornado really non-blocking?

流过昼夜 提交于 2019-11-30 03:45:24
Tornado advertises itself as "a relatively simple, non-blocking web server framework" and was designed to solve the C10k problem. However, looking at their database wrapper, which wraps MySQLdb, I came across the following piece of code: def _execute(self, cursor, query, parameters): try: return cursor.execute(query, parameters) except OperationalError: logging.error("Error connecting to MySQL on %s", self.host) self.close() raise As far as I know calls to the MySQLdb, which is built on top of libmysqlclient , are blocking. Am I right in thinking that a long-running query would render the

Is there a Push-based/Non-blocking XML Parser for Java?

≡放荡痞女 提交于 2019-11-30 01:12:57
I'm looking for an XML parser that instead of parsing from an InputStream or InputSource will instead allow blocks of text to be pushed into the parser. E.g. I would like to have something like the following: public class DataReceiver { private SAXParser parser = //... private DefaultHandler handler = //... /** * Called each time some data is received. */ public void onDataReceived(byte[] data) { parser.push(data, handler); } } The reason is that I would like something that will play nice with the NIO networking libraries rather than having to revert back to a thread per connection model

When a non-blocking send() only transfers partial data, can we assume it would return EWOULDBLOCK the next call?

白昼怎懂夜的黑 提交于 2019-11-29 23:14:51
Two cases are well-documented in the man pages for non-blocking sockets: If send() returns the same length as the transfer buffer, the entire transfer finished successfully, and the socket may or may not be in a state of returning EAGAIN/EWOULDBLOCK the next call with >0 bytes to transfer. If send() returns -1 and errno is EAGAIN/EWOULDBLOCK, none of the transfer finished, and the program needs to wait until the socket is ready for more data (EPOLLOUT in the epoll case). What's not documented for nonblocking sockets is: If send() returns a positive value smaller than the buffer size. Is it

Non-blocking javascript and css in modern browsers. Is it still needed?

柔情痞子 提交于 2019-11-29 20:42:47
I am playing a little with some non-blocking JavaScript loading. This means I have a small snippet of JavaScript in my head , and load all my external files at runtime. I even took it a little further to load CSS non-blocking. I see the articles I could find are a little outdated, that is why I want to know if this is all still relevant. Now first the scripts, they look like this: <script> (function () { var styles = JSON.parse(myObject.styles); for( name in styles ){ var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('type', 'text/css'); link

How to check if stdin is still opened without blocking?

倖福魔咒の 提交于 2019-11-29 18:34:31
问题 I need my program written in pure C to stop execution when stdin is closed. There is indefinite work done in program main cycle, and there is no way I can use blocking checks (like getc() ) there (no data is supposed to arrive on stdin - it just stays opened for unknown time). I intend to use described functionality in realization of network daemon hosted in inetd, xinetd or their analogs - it should emit data on stdout while connection stays opened and correctly finish work when it closes.

Is there a non-blocking version of MessageBox.Show (or something like it)?

吃可爱长大的小学妹 提交于 2019-11-29 15:59:21
问题 Long-delayed update I'm accepting MUG4N's answer to this question, and I also want to respond to some of the criticisms that were raised against it. ChrisF said: ...you can't make UI calls directly from background threads. This is a blanket statement, and is not 100% true. Let me just point out a few facts: You can actually make UI calls all you want if you set Control.CheckForIllegalCrossThreadCalls = false . "Ack!" I hear you saying. "Don't ever do that!" Yes, yes -- but why ? The answer:

Javascript non-blocking scripts, why don't simply put all scripts before </body> tag?

风流意气都作罢 提交于 2019-11-29 12:17:02
问题 In order to avoid javascript to block webpage rendering, can't we just put all all our JS files/code to be loaded/executed simply before the closing </body> tag? All JS files and code would be downloaded and executed only after the all page has being rendered, so what's the need for tricks like the one suggested in this article about non blocking techniques to load JS files . He basically suggests to use code like: document.getElementsByTagName("head")[0].appendChild(script); in order to

Sockets in C#, how can I asynchronously read and write data through a NetworkStream

橙三吉。 提交于 2019-11-29 12:12:58
[I am limited to Visual Studio 2010, and therefore, C# 4. async and await are not available to me.] I'm working on network architecture for a project of mine, that sends packets of data over a network between a server and a client, but the client and server must continue running while waiting, so the code has to be non-blocking, so I thought to use the asynchronous methods. However, except for simple synchronous one-time IO, I don't know much about what to do, especially when using a NetworkStream. What I'm trying to do is: 1) Client connects to server 2) Server accepts connection 3) Server

Atomic Instruction

白昼怎懂夜的黑 提交于 2019-11-29 11:07:50
What do you mean by Atomic instructions? How does the following become Atomic? TestAndSet int TestAndSet(int *x){ register int temp = *x; *x = 1; return temp; } From a software perspective, if one does not want to use non-blocking synchronization primitives, how can one ensure Atomicity of instruction? is it possible only at Hardware or some assembly level directive optimization can be used? Some machine instructions are intrinsically atomic - for example, reading and writing properly aligned values of the native processor word size is atomic on many architectures . This means that hardware