Search Results

Search found 466 results on 19 pages for 'polling'.

Page 15/19 | < Previous Page | 11 12 13 14 15 16 17 18 19  | Next Page >

  • Blockchain API, AJAX request has stopped working, CORS issues?

    - by Sly
    I've been playing with the multiple address look up API from blockchain info (documented here https://blockchain.info/api/blockchain_api), I had my code working earlier in the day but bizzarely it's stopped. The purpose of it is to eventually write a little JQuery library which will search the DOM for bitcoin addresses as data attributes and then insert the final balance into that element creating a polling mechanism to keep the page updated as well. The original problem I ran into earlier while developing it was because it's a CORS ajax request but later I adjusted the query per the blockchain info API documents and I added cors=true it then seemed to work fine but now it doesn't seem to want to work at all again. I don't get how changing computers would effect this kind of request. Here's my code on JSFiddle, http://jsfiddle.net/SlyFoxy12/9mr7L/7/ My primary code is: (function ($) { var methods = { init: function(data, options) { //put your init logic here. }, query_addresses: function(addresses) { var addresses_implode = addresses.join("|"); $.getJSON("http://blockchain.info/multiaddr?cors=true&active="+addresses_implode, function( data ) { $.each( data.addresses, function( index ) { $('#output').append(" "+data.addresses[index].final_balance); }); }); } }; $.fn.bitstrap = function () { var addresses = new Array(); $('[data-xbt-address]').each(function () { $(this).text($(this).data('xbtAddress')); addresses.push($(this).data('xbtAddress')); }); methods.query_addresses(addresses); } }(jQuery)); $().ready(function() { $().bitstrap(); });

    Read the article

  • Scope of Connection Object for a Website using Connection Pooling (Local or Instance)

    - by Danny
    For a web application with connection polling enabled, is it better to work with a locally scoped connection object or instance scoped connection object. I know there is probably not a big performance improvement between the two (because of the pooling) but would you say that one follows a better pattern than the other. Thanks ;) public class MyServlet extends HttpServlet { DataSource ds; public void init() throws ServletException { ds = (DataSource) getServletContext().getAttribute("DBCPool"); } protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { SomeWork("SELECT * FROM A"); SomeWork("SELECT * FROM B"); } void SomeWork(String sql) { Connection conn = null; try { conn = ds.getConnection(); // execute some sql ..... } finally { if(conn != null) { conn.close(); // return to pool } } } } Or public class MyServlet extends HttpServlet { DataSource ds; Connection conn;* public void init() throws ServletException { ds = (DataSource) getServletContext().getAttribute("DBCPool"); } protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { try { conn = ds.getConnection(); SomeWork("SELECT * FROM A"); SomeWork("SELECT * FROM B"); } finally { if(conn != null) { conn.close(); // return to pool } } } void SomeWork(String sql) { // execute some sql ..... } }

    Read the article

  • How to have Android Service communicate with Activity

    - by Scott Saunders
    I'm writing my first Android application and trying to get my head around communication between services and activities. I have a Service that will run in the background and do some gps and time based logging. I will have an Activity that will be used to start and stop the Service. So first, I need to be able to figure out if the Service is running when the Activity is started. There are some other questions here about that, so I think I can figure that out (but feel free to offer advice). My real problem: if the Activity is running and the Service is started, I need a way for the Service to send messages to the Activity. Simple Strings and integers at this point - status messages mostly. The messages will not happen regularly, so I don't think polling the service is a good way to go if there is another way. I only want this communication when the Activity has been started by the user - I don't want to start the Activity from the Service. In other words, if you start the Activity and the Service is running, you will see some status messages in the Activity UI when something interesting happens. If you don't start the Activity, you will not see these messages (they're not that interesting). It seems like I should be able to determine if the Service is running, and if so, add the Activity as a listener. Then remove the Activity as a listener when the Activity pauses or stops. Is that actually possible? The only way I can figure out to do it is to have the Activity implement Parcelable and build an AIDL file so I can pass it through the Service's remote interface. That seems like overkill though, and I have no idea how the Activity should implement writeToParcel() / readFromParcel(). Is there an easier or better way? Thanks for any help.

    Read the article

  • .NET Remoting memory leak?

    - by PrimeTSS
    I have a Remoting Class as a Singleton <configuration> <system.runtime.remoting> <application> <service> <wellknown mode="Singleton" type="PTSSLinkClasses.PTSSLinkClientDesktopRemotable, PTSSLinkClasses" objectUri="PTSSLinkDesktop" /> </service> <channels> <channel ref="http" port="8901"/> </channels> </application> </system.runtime.remoting> </configuration> Its created within a "server" Service. Another client service consumes this remote object. The client is calling the remote object every .5 second using a timer (polling) (for testing) If the server service is stopped, so the remote object is not available, memory useage for the client service keeps increasing...... I have overwritten InitialLifetimeService to return a null public override Object InitializeLifetimeService() { return null; } If a remote object is not available does .net queue all the call requests to this object??? untill all the memory is consumed? How can I dected if the remote object is not available and stop trying to call the remote method?

    Read the article

  • Windows system monitoring and profiling

    - by Aris
    I have several dozen 64-bit Windows 2003 servers in a high performance environment with very bursty system utilization. I am looking for a tool (or tools) to monitor and analyze system performance (eg, CPU utilization, bandwidth, etc). This tool can either query servers from a central location (SNMP) or require installation of a component on each server. It should poll on a 1-second interval. It should be able to generate pretty graphs which show trends over time. As a nice-to-have, it should be able to send out emails or IMs when certain thresholds are exceeded. The tools I have investigated so far, including Solarwinds and PRTG, are not designed to poll this frequently. They seem to be designed for a ~30-second interval. Solarwinds wouldn't go lower than 3-sec, and PRTG chokes at 1-sec. They both default to 1-min. All three tools seem more focused on outage monitoring and reporting than metric collection. Given the bursty nature of our applications, such infrequent polling would result in a very inaccurate picture of performance. I am considering rolling my own solution using perfmon. This would be a lot of work, and seems like reinventing the wheel. Are there any tools out there that meet my needs?

    Read the article

  • Using HAML with custom filters

    - by Guard
    Hi everybody. I feel quite excited about HAML and CoffeeScript and am working on tutorial showing how to use them in non-Rails environment. So, haml has easy to use command-line utility haml input.haml output.html. And, what is great, there exist a project (one of many forks: https://github.com/aussiegeek/coffee-haml-filter) aimed at providing custom filter that converts CoffeeScript into JS inside of HAML files. Unfortunately (or am I missing something?) haml doesn't allow specifying custom filters on the command line or with some configuration file. I (not being a Ruby fan or even knowing it enough) managed to solve it (based on some clever suggestion somewhere on SO) with this helper script: haml.rb require 'rubygems' require 'active_support/core_ext/object/blank' require 'haml' require 'haml/filters/coffee' template = ARGV.length > 0 ? File.read(ARGV.shift) : STDIN.read haml_engine = Haml::Engine.new(template) file = ARGV.length > 0 ? File.open(ARGV.shift, 'w') : STDOUT file.write(haml_engine.render) file.close Which is quite straightforward, except of requires in the beginning. Now, the questions are: 1) should I really use it, or is there another way to have on-demand HAML to HTML compilation with custom filters? 2) What about HAML watch mode? It's great and convenient. I can, of course, create a polling script in python that will watch the directory changes and call this .rb script, but it looks like a dirty solution.

    Read the article

  • C++ thread safety - exchange data between worker and controller

    - by peterchen
    I still feel a bit unsafe about the topic and hope you folks can help me - For passing data (configuration or results) between a worker thread polling something and a controlling thread interested in the most recent data, I've ended up using more or less the following pattern repeatedly: Mutex m; tData * stage; // temporary, accessed concurrently // send data, gives up ownership, receives old stage if any tData * Send(tData * newData) { ScopedLock lock(m); swap(newData, stage); return newData; } // receiving thread fetches latest data here tData * Fetch(tData * prev) { ScopedLock lock(m); if (stage != 0) { // ... release prev prev = stage; stage = 0; } return prev; // now current } Note: This is not supposed to be a full producer-consumer queue, only the msot recent data is relevant. Also, I've skimmed ressource management somewhat here. When necessary I'm using two such stages: one to send config changes to the worker, and for sending back results. Now, my questions assuming that ScopedLock implements a full memory barrier: do stage and/or workerData need to be volatile? is volatile necessary for tData members? can I use smart pointers instead of the raw pointers - say boost::shared_ptr? Anything else that can go wrong? I am basically trying to avoid "volatile infection" spreading into tData, and minimize lock contention (a lock free implementation seems possible, too). However, I'm not sure if this is the easiest solution. ScopedLock acts as a full memory barrier. Since all this is more or less platform dependent, let's say Visual C++ x86 or x64, though differences/notes for other platforms are welcome, too. (a prelimenary "thanks but" for recommending libraries such as Intel TBB - I am trying to understand the platform issues here)

    Read the article

  • What are alternatives to Win32 PulseEvent() function?

    - by Bill
    The documentation for the Win32 API PulseEvent() function (kernel32.dll) states that this function is “… unreliable and should not be used by new applications. Instead, use condition variables”. However, condition variables cannot be used across process boundaries like (named) events can. I have a scenario that is cross-process, cross-runtime (native and managed code) in which a single producer occasionally has something interesting to make known to zero or more consumers. Right now, a well-known named event is used (and set to signaled state) by the producer using this PulseEvent function when it needs to make something known. Zero or more consumers wait on that event (WaitForSingleObject()) and perform an action in response. There is no need for two-way communication in my scenario, and the producer does not need to know if the event has any listeners, nor does it need to know if the event was successfully acted upon. On the other hand, I do not want any consumers to ever miss any events. In other words, the system needs to be perfectly reliable – but the producer does not need to know if that is the case or not. The scenario can be thought of as a “clock ticker” – i.e., the producer provides a semi-regular signal for zero or more consumers to count. And all consumers must have the correct count over any given period of time. No polling by consumers is allowed (performance reasons). The ticker is just a few milliseconds (20 or so, but not perfectly regular). Raymen Chen (The Old New Thing) has a blog post pointing out the “fundamentally flawed” nature of the PulseEvent() function, but I do not see an alternative for my scenario from Chen or the posted comments. Can anyone please suggest one? Please keep in mind that the IPC signal must cross process boundries on the machine, not simply threads. And the solution needs to have high performance in that consumers must be able to act within 10ms of each event.

    Read the article

  • BackgroundWorker From ASP.Net Application

    - by Kevin
    We have an ASP.Net application that provides administrators to work with and perform operations on large sets of records. For example, we have a "Polish Data" task that an administrator can perform to clean up data for a record (e.g. reformat phone numbers, social security numbers, etc.) When performed on a small number of records, the task completes relatively quickly. However, when a user performs the task on a larger set of records, the task may take several minutes or longer to complete. So, we want to implement these kinds of tasks using some kind of asynchronous pattern. For example, we want to be able to launch the task, and then use AJAX polling to provide a progress bar and status information. I have been looking into using the BackgroundWorker class, but I have read some things online that make me pause. I would love to get some additional advice on this. For example, I understand that the BackgroundWorker will actually use the thread pool from the current application. In my case, the application is an ASP.Net web site. I have read that this can be a problem because when the application recycles, the background workers will be terminated. Some of the jobs I mentioned above may take 3 minutes, but others may take a few hours. Also, we may have several hundred administrators all performing similar operations during the day. Will the ASP.Net application thread pool be able to handle all of these background jobs efficiently while still performing it's normal request processing? So, I am trying to determine if using the BackgroundWorker class and approach is right for our needs. Should I be looking at an alternative approach? Thanks and sorry for such a long post! Kevin

    Read the article

  • echo command not found while testing selenium with phpunit

    - by Bill Szerdy
    I am getting an ERROR: Unknown command: 'echo' executing a selenium script with phpunit. Based on the output that echo command should be included in my version of PHPUnit. The selenium script does execute successfully in the firefox selenium IDE. mkdir_build: phpunit: [exec] PHPUnit 3.4.12 by Sebastian Bergmann. [exec] [exec] . [exec] TestFull [exec] E [exec] [exec] Time: 11 seconds, Memory: 6.50Mb [exec] [exec] There was 1 error: [exec] [exec] 1) TestFull::testNumberOne [exec] PHPUnit_Framework_Exception: Response from Selenium RC server for testComplete(). [exec] ERROR: Unknown command: 'echo'. [exec] [exec] [exec] /directory/to/tests/TestFull.php:14 [exec] [exec] FAILURES! [exec] Tests: 1, Assertions: 0, Errors: 1. And the RC server output: $ java -jar selenium-server.jar -port 4445 -debug 13:23:08.426 INFO - Java: Sun Microsystems Inc. 14.2-b01 13:23:08.428 INFO - OS: Linux 2.6.28-15-server i386 13:23:08.439 INFO - v2.0 [a2], with Core v2.0 [a2] 13:23:08.439 INFO - Selenium server running in debug mode. 13:25:05.661 DEBUG - ---------retrieving CommandQueue for sel_93352 13:25:05.662 DEBUG - Browser 2c8b3b5657a640db9fb278ecbd01049e/:top sel_93352 posted ERROR: Unknown command: 'echo' 13:25:05.662 DEBUG - ---------retrieving CommandQueue for sel_93352 13:25:05.662 DEBUG - putting command: ERROR: Unknown command: 'echo' 13:25:05.662 DEBUG - ..command put?: true 13:25:05.662 DEBUG - sel_93352 commandHolder sel_93352 getCommand() called 13:25:05.662 DEBUG - waiting for data for at most 10 more s 13:25:05.662 DEBUG - data from polling: ERROR: Unknown command: 'echo' 13:25:05.662 DEBUG - sel_93352 commandResultHolder sel_93352 getResult() -> ERROR: Unknown command: 'echo' 13:25:05.663 DEBUG - Got result: ERROR: Unknown command: 'echo' on session 2c8b3b5657a640db9fb278ecbd01049e 13:25:05.663 INFO - Got result: ERROR: Unknown command: 'echo' on session 2c8b3b5657a640db9fb278ecbd01049e 13:25:05.663 DEBUG - Handled by org.openqa.selenium.server.SeleniumDriverResourceHandler in HttpContext[/selenium-server,/selenium-server] 13:25:05.663 DEBUG - RESPONSE: HTTP/1.1 200 OK Date: Wed, 07 Apr 2010 20:25:05 GMT Server: Jetty/5.1.x (Linux/2.6.28-15-server i386 java/1.6.0_16 Cache-Control: no-cache Pragma: no-cache Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: text/plain Connection: close

    Read the article

  • How to implement a web app with blazeds+java+flex+tomcat?

    - by ARYAD
    Hi, i'm doing a web app in flex blazeds and java, i installed the eclipse plugs for using WTP mixed project, i use the flex's server that uses an emulate of tomcat when i ran my flex service the web app got the datas, everythings is ok. the problem is when i copy the proyect with all files generated by flex in my tomcat or the blazeds's tomcat, it doesn't work, this is becasue i want to implement my app on a server the error is: "(mx.messaging.messages::ErrorMessage)#0 body = (Object)#1 clientId = (null) correlationId = "B425A2A7-7D12-A982-7779-8CCBF669413C" destination = "" extendedData = (null) faultCode = "Client.Error.MessageSend" faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf'" faultString = "Send failed" headers = (Object)#2 messageId = "1CBC6020-0ED8-C4CC-3B77-8CCBF6D6621D" rootCause = (mx.messaging.events::ChannelFaultEvent)#3 bubbles = false cancelable = false channel = (mx.messaging.channels::AMFChannel)#4 authenticated = false channelSets = (Array)#5 [0] (mx.messaging::ChannelSet)#6 authenticated = false channelIds = (Array)#7 [0] "my-amf" channels = (Array)#8 [0] (mx.messaging.channels::AMFChannel)#4 clustered = false connected = false currentChannel = (mx.messaging.channels::AMFChannel)#4 initialDestinationId = (null) messageAgents = (Array)#9 [0] (mx.rpc::AsyncRequest)#10 authenticated = false autoConnect = true channelSet = (mx.messaging::ChannelSet)#6 clientId = (null) connected = false defaultHeaders = (null) destination = "ADEscenario" id = "7D92EDF2-CF62-9545-BA11-8CCBF6691E6B" reconnectAttempts = 0 reconnectInterval = 0 requestTimeout = -1 subtopic = "" connected = false connectTimeout = -1 enableSmallMessages = true endpoint = "http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf" failoverURIs = (Array)#11 id = "my-amf" mpiEnabled = false netConnection = (flash.net::NetConnection)#12 client = (mx.messaging.channels::AMFChannel)#4 connected = false objectEncoding = 3 proxyType = "none" uri = "http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf" piggybackingEnabled = false polling = false pollingEnabled = true pollingInterval = 3000 protocol = "http" reconnecting = false recordMessageSizes = false recordMessageTimes = false requestTimeout = -1 uri = "http://{server.name}:{server.port}/IEC-BLAZEDS/messagebroker/amf" url = "http://{server.name}:{server.port}/IEC-BLAZEDS/messagebroker/amf" useSmallMessages = false channelId = "my-amf" connected = false currentTarget = (mx.messaging.channels::AMFChannel)#4 eventPhase = 2 faultCode = "Channel.Connect.Failed" faultDetail = "NetConnection.Call.Failed: HTTP: Failed: url: 'http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf'" faultString = "error" reconnecting = false rejected = false rootCause = (Object)#13 code = "NetConnection.Call.Failed" description = "HTTP: Failed" details = "http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf" level = "error" target = (mx.messaging.channels::AMFChannel)#4 type = "channelFault" timestamp = 0 timeToLive = 0" i don't know why tomcat doesn't find the class of flex.messaging.endpoints.AMFEndpoint that is used for my-amf 'http://172.16.8.245:8400/IEC-BLAZEDS/messagebroker/amf'. all works well in the emulated server that flex has.

    Read the article

  • full duplex communication over the web w/o flash sockets

    - by aharon
    A web application I'm helping to develop is faced with a well-known problem: we want to be able to let users know of various events and so forth that can occur at any time, essentially at random, and update their view accordingly. Essentially, we need to allow the server to push requests to individual clients, as opposed to the client asking the server. I understand that WebSockets are an effort to address the problem; however, after a bit of looking around into them, I understand that a) very few web browsers currently offer native websocket support; b) to get around this, you either use flash sockets or some sort of AJAX long-polling; c) a special websockets server must be used. Now, we want to offer our service without Flash. And any sort of servers must have some sort of load-balancing capabilities, or at least some software that can do load balancing for them. As of 2008, everyone was saying that Comet-based solutions (e.g., Bayeux) were the way to go for these sort of situations. However, the various protocols seem to have not had much work put into them since then—which leads (finally) to the question. Is Bayeux-flavored Comet still the right tool for jobs like this? If not, what is?

    Read the article

  • EPIPE blocks server

    - by timn
    I have written a single-threaded asynchronous server in C running on Linux: The socket is non-blocking and as for polling, I am using epoll. Benchmarks show that the server performs fine and according to Valgrind, there are no memory leaks or other problems. The only problem is that when a write() command is interrupted (because the client closed the connection), the server will encounter a SIGPIPE. I am doing the interrupted artifically by running the benchmarking utility "siege" with the parameter -b. It does lots of requests in a row which all work perfectly. Now I press CTRL-C and restart the "siege". Sometimes I am lucky and the server does not manage to send the full response because the client's fd is invalid. As expected errno is set to EPIPE. I handle this situation, execute close() on the fd and then free the memory related to the connection. Now the problem is that the server blocks and does not answer properly anymore. Here is the strace output: accept(3, {sa_family=AF_INET, sin_port=htons(50611), sin_addr=inet_addr("127.0.0.1")}, [16]) = 5 fcntl64(5, F_GETFD) = 0 fcntl64(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 epoll_ctl(4, EPOLL_CTL_ADD, 5, {EPOLLIN|EPOLLERR|EPOLLHUP|EPOLLET, {u32=158310248, u64=158310248}}) = 0 epoll_wait(4, {{EPOLLIN, {u32=158310248, u64=158310248}}}, 128, -1) = 1 read(5, "GET /user/register HTTP/1.1\r\nHos"..., 4096) = 161 write(5, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 106) = 106 <<<<< write(5, "00001000\r\n", 10) = -1 EPIPE (Broken pipe) <<<<< Why did the previous write() work fine but not this one? --- SIGPIPE (Broken pipe) @ 0 (0) --- As you can see, the client establishes a new connection which consequently is accepted. Then, it's added to the EPOLL queue. epoll_wait() signalises that the client sent data (EPOLLIN). The request is parsed and and a response is composed. Sending the headers works fine but when it comes to the body, write() results in an EPIPE. It is not a bug in "siege" because it blocks any incoming connections, no matter from which client.

    Read the article

  • 4.0/WCF: Best approach for bi-idirectional message bus?

    - by TomTom
    Just a technology update, now that .NET 4.0 is out. I write an application that communicates to the server through what is basically a message bus (instead of method calls). This is based on the internal architecture of the application (which is multi threaded, passing the messages around). There are a limited number of messages to go from the client to the server, quite a lot more from the server to the client. Most of those can be handled via a separate specialized mechanism, but at the end we talk of possibly 10-100 small messages per second going from the server to the client. The client is supposed to operate under "internet conditions". THis means possibly home end users behind standard NAT devices (i.e. typical DSL routers) - a firewalled secure and thus "open" network can not be assumed. I want to have as little latency and as little overhad for the communication as possible. What is the technologally best way to handle the message bus callback? I Have no problem regularly calling to the server for message delivery if something needs to be sent... ...but what are my options to handle the messagtes from the server to the client? WsDualHttp does work how? Especially under a NAT scenario? Just as a note: polling is most likely out - the main problem here is that I would have a significant overhead OR a significant delay, both aren ot really wanted. Technically I would love some sort of streaming appraoch, where the server can write messags to a stream while he generates them and they get sent to the client as they come. Not esure this is doable with WCF, though (if not, I may acutally decide to handle the whole message part outside of WCF and just do control / login / setup / destruction via WCF).

    Read the article

  • "Work stealing" vs. "Work shrugging"?

    - by John
    Why is it that I can find lots of information on "work stealing" and nothing on "work shrugging" as a dynamic load-balancing strategy? By "work-shrugging" I mean busy processors pushing excessive work towards less loaded neighbours rather than idle processors pulling work from busy neighbours ("work-stealing"). I think the general scalability should be the same for both strategies. However I believe that it is much more efficient for busy processors to wake idle processors if and when there is definitely work for them to do than having idle processors spinning or waking periodically to speculatively poll all neighbours for possible work. Anyway a quick google didn't show up anything under the heading of "Work Shrugging" or similar so any pointers to prior-art and the jargon for this strategy would be welcome. Clarification/Confession In more detail:- By "Work Shrugging" I actually envisage the work submitting processor (which may or may not be the target processor) being responsible for looking around the immediate locality of the preferred target processor (based on data/code locality) to decide if a near neighbour should be given the new work instead because they don't have as much work to do. I am talking about an atomic read of the immediate (typically 2 to 4) neighbours' estimated q length here. I do not think this is any more coupling than implied by the thieves polling & stealing from their neighbours - just much less often - or rather - only when it makes economic sense to do so. (I am assuming "lock-free, almost wait-free" queue structures in both strategies). Thanks.

    Read the article

  • Asynchronous event loop design and issues.

    - by Artyom
    Hello, I'm designing event loop for asynchronous socket IO using epoll/devpoll/kqueue/poll/select (including windows-select). I have two options of performing, IO operation: Non-blocking mode, poll on EAGAIN Set socket to non-blocking mode. Read/Write to socket. If operation succeeds, post completion notification to event loop. If I get EAGAIN, add socket to "select list" and poll socket. Polling mode: poll and then execute Add socket to select list and poll it. Wait for notification that it is readable writable read/write Post completion notification to event loop of sucseeds To me it looks like first would require less system calls when using in normal mode, especially for writing to socket (buffers are quite big). Also it looks like that it would be possible to reduce the overhead over number of "select" executions, especially it is nice when you do not have something that scales well as epoll/devpoll/kqueue. Questions: Are there any advantages of the second approach? Are there any portability issues with non-blocking operations on sockets/file descriptors over numerous operating systems: Linux, FreeBSD, Solaris, MacOSX, Windows. Notes: Please do not suggest using existing event-loop/socket-api implementations

    Read the article

  • Wait on multiple condition variables on Linux without unnecessary sleeps?

    - by Joseph Garvin
    I'm writing a latency sensitive app that in effect wants to wait on multiple condition variables at once. I've read before of several ways to get this functionality on Linux (apparently this is builtin on Windows), but none of them seem suitable for my app. The methods I know of are: Have one thread wait on each of the condition variables you want to wait on, which when woken will signal a single condition variable which you wait on instead. Cycling through multiple condition variables with a timed wait. Writing dummy bytes to files or pipes instead, and polling on those. #1 & #2 are unsuitable because they cause unnecessary sleeping. With #1, you have to wait for the dummy thread to wake up, then signal the real thread, then for the real thread to wake up, instead of the real thread just waking up to begin with -- the extra scheduler quantum spent on this actually matters for my app, and I'd prefer not to have to use a full fledged RTOS. #2 is even worse, you potentially spend N * timeout time asleep, or your timeout will be 0 in which case you never sleep (endlessly burning CPU and starving other threads is also bad). For #3, pipes are problematic because if the thread being 'signaled' is busy or even crashes (I'm in fact dealing with separate process rather than threads -- the mutexes and conditions would be stored in shared memory), then the writing thread will be stuck because the pipe's buffer will be full, as will any other clients. Files are problematic because you'd be growing it endlessly the longer the app ran. Is there a better way to do this? Curious for answers appropriate for Solaris as well.

    Read the article

  • Special technology needed for browser based chat?

    - by orokusaki
    On this post, I read about the usage of XMPP. Is this sort of thing necessary, and more importantly, my main question expanded: Can a chat server and client be built efficiently using only standard HTTP and browser technologies (such as PHP and JS, or RoR and JS, etc)? Or, is it best to stick with old protocols like XMPP find a way to integrate them with my application? I looked into CampFire via LiveHTTPHeaders and Firebug for about 5 minutes, and it appears to use Ajax to send a request which is never answered until another chat happens. Is this just CampFire opening a new thread on the server to listen for an update and then returning a response to the request when the thread hears an update? I noticed that they're requesting on a specific port (8043 if memory serves me) which makes me think that they're doing something more complex than just what I mentioned. Also, the URL requested started with /tcp/ which I found interesting. Note: I don't expect to ever have more than 150 users live-chatting in all the rooms combined at the same time. I understand that if I was building a hosted pay for chat service like CampFire with thousands of concurrent users, it would behoove me to invest time in researching special technologies vs trying to reinvent the wheel in a simple way in my app. Also, if you're going to do it with server polling, how often would you personally poll to maximize response without slamming the server?

    Read the article

  • How to receive Email in JEE application

    - by Hank
    Obviously it's not so difficult to send out emails from a JEE application via JavaMail. What I am interested in is the best pattern to receive emails (notification bounces, mostly)? I am not interested in IMAP/POP3-based approaches (polling the inbox) - my application shall react to inbound emails. One approach I could think of would be Keep existing MTA (postfix on linux in my case) - ops team already knows how to configure / operate it For every mail that arrives, spawn a Java app that receives the data and sends it off via JMS. I could do this via an entry in /etc/aliases like myuser: "|/path/to/javahelper" with javahelper calling the Java app, passing STDIN along. MDB (part of JEE application) receives JMS message, parses it, detects bounce message and acts accordingly. Another approach could be Open a listening network socket on port 25 on the JEE application container. Associate a SessionBean with the socket. Bean is part of JEE application and can parse/detect bounces/handle the messages directly. Keep existing MTA as inbound relay, do all its security/spam filtering, but forward emails to myuser (that pass the filter) to the JEE application container, port 25. The first approach I have done before (albeit in a different language/setup). From a performance and (perceived) cleanliness point of view, I think the second approach is better, but it would require me to provide a proper SMTP transport implementation. Also, I don't know if it's at all possible to connect a network socket with a bean... What is your recommendation? Do you have details about the second approach?

    Read the article

  • Strategy for WCF server with .Net clients and Android clients?

    - by D.H.
    I am using WCF to write a server that should be able to communicate with .Net clients, Android clients and possibly other types of clients. The main type of client is a desktop application that will be written in .Net. This client will usually be on the same intranet as the server. It will make an initial call to the server to get the current state of the system and will then receive updates from the server whenever a value changes. These updates are frequent, perhaps once a second. The Android clients will connect over the Internet. This client is also interested in updates, but it is not as critical as for the desktop client so a (less frequent) polling scenario might be acceptable. All clients will have to login to use the services, and when connecting over the Internet the connection should be secure. I am familiar with WCF but I am not sure what bindings are most appropriate for the scenario and what security solution to use. Also, I have not used Android, but I would like to make it as simple as possible for the person implementing the Android client to consume my services. So, what is my strategy?

    Read the article

  • Multi-account sync with Dropbox API

    - by Dan
    I'm trying to create a web app that lets users share files with each other through Dropbox. At the moment, Dropbox handles all the sharing, and there's one central Dropbox account running on the web server that shares the folder with the people who want it. I'm trying to change it so people don't have to accept a new folder invitation each time. I'd like to have them authorize my app to access an app folder in their Dropbox account, and all their shared folders would go inside there. Any changes they make would get noticed by the app on the server and synced to everyone else's folders. There's a couple things I'm having trouble figuring out to make this work: Do I need to make repeated calls to /delta for every account? I can't think how else I'd do this, but that sounds like it would quickly turn into thousands of requests a minute just polling for updates. When someone adds a file, do I have to upload it once for each account? That seems like a huge waste of bandwidth. I've looked into using /copy_ref, which I think would add a file to another user's account without my app ever touching it, but my app's web interface also allows users to upload files directly to my server, which would then need to be synced with everyone else's folders. That file isn't on Dropbox's servers yet, so /copy_ref obviously wouldn't work. For a little extra context, my app is written in node.js, and I've been playing with this library to interface with Dropbox, which uses their REST API.

    Read the article

  • Handling user interface in a multi-threaded application (or being forced to have a UI-only main thre

    - by Patrick
    In my application, I have a 'logging' window, which shows all the logging, warnings, errors of the application. Last year my application was still single-threaded so this worked [quite] good. Now I am introducing multithreading. I quickly noticed that it's not a good idea to update the logging window from different threads. Reading some articles on keeping the UI in the main thread, I made a communication buffer, in which the other threads are adding their logging messages, and from which the main thread takes the messages and shows them in the logging window (this is done in the message loop). Now, in a part of my application, the memory usage increases dramatically, because the separate threads are generating lots of logging messages, and the main thread cannot empty the communication buffer quickly enough. After the while the memory decreases again (if the other threads have finished their work and the main thread gradually empties the communication buffer). I solved this problem by having a maximum size on the communication buffer, but then I run into a problem in the following situation: the main thread has to perform a complex action the main thread takes some parts of the action and let's separate threads execute this while the seperate threads are executing their logic, the main thread processes the results from the other threads and continues with its work if the other threads are finished Problem is that in this situation, if the other threads perform logging, there is no UI-message loop, and so the communication buffer is filled, but not emptied. I see two solutions in solving this problem: require the main thread to do regular polling of the communication buffer only performing user interface logic in the main thread (no other logic) I think the second solution seems the best, but this may not that easy to introduce in a big application (in my case it performs mathematical simulations). Are there any other solutions or tips? Or is one of the two proposed the best, easiest, most-pragmatic solution? Thanks, Patrick

    Read the article

  • How to pair users? (Like Omegle.com)

    - by Carlos Dubus
    Hi, I'm trying to do an Omegle.com clone script, basically for learning purposes. I'm doing it in PHP/MySQL/AJAX. I'm having problems finding two users and connecting them. The purpose of omegle is connecting two users "randomly". What I'm doing right now is the following: When a user enters the website a session is assigned. There are 3 states for each session/user (Normal,Waiting,Chatting) At first the user has state Normal and a field "connected_to" = NULL If the users clicks the START button, a state of "Waiting" is assigned. Then it looks for another user with state Waiting, if doesn't find one then it keeps looping, waiting for the "connected_to" to change. The "connected_to" will change when other user click START and then find another user waiting and updates the sessions accordingly. Now this have several problems, like: A user only can be connected to one user at a time. In omegle you can open more than one chat simultaneously. I don't know if this is the best way. About the chat, each user is polling the events from the server with AJAX calls, I saw that omegle, instead of several HTTP requests each second (let's say), does ONE request and wait for an answer, that means that the PHP script is looping indefinitely until gets an answer.I did this using set_time_limit(30) each time the loop is started. Then when the Ajax call is done start over again. Is this approach correct? I will appreciate a LOT your answers, Thank you, Carlos

    Read the article

  • how to do display text message from cellphone to textbox

    - by Jiggy Degamo
    I am just making a project automated polling system using sms but i just a beginner of serial communication i have seen a code on the net so i apply it as my guide just a simple text message and display it on the textbox it connects but the provlem is its didn't display on the textbox. here is the code below please help me why it didn't display and please give me a cite that have a tutorial of serial communication using vb.net Imports System.IO.Ports Public Class Form1 Dim inputData As String = "" Private WithEvents serialPort1 As New IO.Ports.SerialPort Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed ' Close the Serial Port serialPort1.Close() End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Set values for some properties serialPort1.PortName = "COM10" serialPort1.BaudRate = 2400 SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.DataBits = 8 SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.Handshake = IO.Ports.Handshake.None SerialPort1.RtsEnable = True ' Open the Serial Port SerialPort1.Open() 'Writes data to the Serial Port output buffer If SerialPort1.IsOpen = True Then SerialPort1.Write("MicroCommand") End If End Sub ' Receive data from the Serial Port 'Show received data on UI controls and do something Public Sub DoUpdate() TextBox1.Text = TextBox1.Text & inputData End Sub Private Sub serialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort1.DataReceived inputData = serialPort1.ReadExisting 'or serialPort1.ReadLine Me.Invoke(New EventHandler(AddressOf DoUpdate)) End Sub End Class

    Read the article

  • Can't iterate over a list class in Python

    - by Vicky
    I'm trying to write a simple GUI front end for Plurk using pyplurk. I have successfully got it to create the API connection, log in, and retrieve and display a list of friends. Now I'm trying to retrieve and display a list of Plurks. pyplurk provides a GetNewPlurks function as follows: def GetNewPlurks(self, since): '''Get new plurks since the specified time. Args: since: [datetime.datetime] the timestamp criterion. Returns: A PlurkPostList object or None. ''' offset = jsonizer.conv_datetime(since) status_code, result = self._CallAPI('/Polling/getPlurks', offset=offset) return None if status_code != 200 else \ PlurkPostList(result['plurks'], result['plurk_users'].values()) As you can see this returns a PlurkPostList, which in turn is defined as follows: class PlurkPostList: '''A list of plurks and the set of users that posted them.''' def __init__(self, plurk_json_list, user_json_list=[]): self._plurks = [PlurkPost(p) for p in plurk_json_list] self._users = [PlurkUser(u) for u in user_json_list] def __iter__(self): return self._plurks def GetUsers(self): return self._users def __eq__(self, other): if other.__class__ != PlurkPostList: return False if self._plurks != other._plurks: return False if self._users != other._users: return False return True Now I expected to be able to do something like this: api = plurk_api_urllib2.PlurkAPI(open('api.key').read().strip(), debug_level=1) plurkproxy = PlurkProxy(api, json.loads) user = plurkproxy.Login('my_user', 'my_pass') ps = plurkproxy.GetNewPlurks(datetime.datetime(2009, 12, 12, 0, 0, 0)) print ps for p in ps: print str(p) When I run this, what I actually get is: <plurk.PlurkPostList instance at 0x01E8D738> from the "print ps", then: for p in ps: TypeError: __iter__ returned non-iterator of type 'list' I don't understand - surely a list is iterable? Where am I going wrong - how do I access the Plurks in the PlurkPostList?

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19  | Next Page >