Wikipedia:Reference desk/Archives/Computing/2011 January 16

{{#ifeq:{{PAGENAME}}|Special:Undelete| |{{#if:|

}} {{#ifeq:{{NAMESPACE}}|Wikipedia|{{#switch:{{NAMESPACE}}|= |
}}|{{error:not substituted|Archive header}}
}}}} {{#if:|
}}
width = "100%"
colspan="3" align="center" | Computing desk
width="20%" align="left" | < January 15

! width="25%" align="center"|<< Dec | January | Feb >>

! width="20%" align="right" |{{#ifexist:Wikipedia:Reference desk/Archives/Computing/2011 January 17|January 17|Current desk}} >

align=center width=95% style="background: #FFFFFF; border: 1px solid #003EBA;" cellpadding="8" cellspacing="0"
style="background: #5D7CBA; text-align: center; font-family:Arial; color:#FFFFFF;" | Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is {{#ifexist:Wikipedia:Reference desk/Archives/Computing/2011 January 26|an archive page|a transcluded archive page}}. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.

__TOC__

= January 16 =

How to keep sockets alive in Java

Hi! I'm developing a Java program between a client and server. Both sides have a thread blocked reading for long periods of time. The problem is I get a SocketException: socket reset after about 5 minutes of not writing on either end of the socket. What's the easiest way to fix this? I'm thinking about writing a nonsense byte to the socket at regular intervals to keep it alive, but that might take some recoding so that it can be recognized and discarded by the reading end. I tried setSO_KeepAlive(true) before connecting the socket, which didn't solve the problem (does it have to be set to true on both ends?). Interestingly, if I run the client and server on a local network, there is a longer interval of inactivity before I get a SocketException: socket reset, but over the Internet it's only about 5 minutes. Anyway, I'd greatly appreciate any solutions or suggestions. Thank you!--el Aprel (facta-facienda) 02:48, 16 January 2011 (UTC)

:Could you specify some versions?Smallman12q (talk) 05:08, 16 January 2011 (UTC)

:I suspect you have a router/firewall that is messing with connections. See if you can configure it not to be so aggressive. Failing that, implement your plan of periodically sending a "nonsense byte" (technically known as an application protocol heartbeat). TCP keepalive does a lower level heartbeat, but the interval of keepalives is of the order of a couple of hours, and there is no API for changing it (operating system level hacks for changing it may exist, but I suggest not going there). 88.112.59.31 (talk) 13:23, 16 January 2011 (UTC)

::Of course, to answer this correctly, we need to know why the Socket is timing out. Sockets don't "die" unless something kills them - usually a firewall. Is there an intermediate firewall between the computers that are communicating? Is either end-point's network driver, operating system, or software-firewall killing the socket after a certain period of inactivity? The answer "depends" and it may be impossible to find out unless you control both endpoints (and all network connections between them). A reasonable workaround is to assume that somebody's firewall is going to kill your socket after some delay. (30 seconds is a common network inactivity timeout on many firewalls with default settings). So if you send a "heartbeat" every 20 seconds, you keep most network connections alive. That heartbeat can be anything (you're programming the server and the client software, right? So just design a "NO_OP" magic byte, or packet, or whatever. Alternatively, for an even safer, more-robust workaround, (that doesn't make any assumptions about firewall-timeout rates), design your network code to be resilient in case of dropped-connection and provide for both client and server to attempt an automatic reconnection using a new Socket object. Note that the [http://download.oracle.com/javase/1.4.2/docs/api/java/net/SocketOptions.html#SO_KEEPALIVE SO_KEEPALIVE] implementation for Java Socket has a hard-coded time-period of approximately 2 hours (for OpenJDK and Sun's JVM implementations); this is much longer than most firewall timeouts, so you'll need a homebrew solution. Nimur (talk) 23:31, 16 January 2011 (UTC)

:::Thanks! I implemented a heartbeat at 20-seconds interval and it's working as expected.--el Aprel (facta-facienda) 04:21, 18 January 2011 (UTC)

The application was unable..

After installing Lunascape browser, I tried to run it. But instead of opening, suddenly a message poped up and said, "The application was unable to start correctly (0xc0000022). Click OK to close the application". I reinstalled the browser but nothing happend except that weird message. It happened several times with another browser like Flock. Mozilla runs fine. How can I fix it?--180.234.45.42 (talk) 11:12, 16 January 2011 (UTC)

  • I had same problem with this browser. Follow these steps: Right click on Lunascape shortcut then go to properties. Click on the shortcut tab, there again click on advance tab and choose "Run as administrator". If the shortcut icon does not appear to be Lunascape, you can change it by clicking on "Change icon tab". Then click OK to close the window. You are done. Same process goes for Chrome browser as well. The problem occurs due to the corruption or missing of Shell 32.dll file. I hope this would help.--NAHID 00:29, 17 January 2011 (UTC)

iPhone to monitor streaming

Is there a way I can stream video (Netflix) from my iPhone 3G to my computer monitor via the Apple-provided USB cable? The OS is Windows XP. Thank you161.165.196.84 (talk) 11:22, 16 January 2011 (UTC)

:I do not think so. Netflix is also available for the PC -- so you should be able to get it directly onto your PC. Happy Computing! Tofutwitch11 (TALK) 14:14, 21 January 2011 (UTC)

Find word and beep

{{resolved}}

I've been searching for a program (for Windows 7) which can scan a url for a word or phrase, and beep or play a sound if it finds it. So far I haven't found anything which meets all the requirements, so I am now trying to make a script myself using .bat which can do this. So far I have wget which can download the url to a file. Now I just need the 'scan for keywords and beep' component. I've tried find (command) and findstr but they don't beep or play a sound. 82.44.55.25 (talk) 13:59, 16 January 2011 (UTC)

:find is your friend, when combined with && echo ^G. Note that the ^G part is entered as [Ctrl]+G.

find "thisiswhatimlookingfor" fooobar.html && echo ^G

-- 188.105.132.219 (talk) 14:04, 17 January 2011 (UTC)

::Thank you! :D 82.44.55.25 (talk) 14:24, 17 January 2011 (UTC)

electronics (ripple)

The percent of ripple for a high-quality power supply is supposed to be 5%. If it is a 12v dc power supply, what is the max amount of ripple you should expect to see at the output. —Preceding unsigned comment added by 98.215.204.87 (talk) 14:35, 16 January 2011 (UTC)

:This probably should have been asked on the science desk. However, the answer is 5% * 12V. Our ripple (electrical) article should cover the measurement of ripple, but neglects to. CS Miller (talk) 15:49, 16 January 2011 (UTC)

Seeking Basic program code to copy folders and files

I have tried seaching for the code for a BASIC program or routine to copy files and folders (including recursively) in Windows, but have not found anything. I would like to be able to overwrite a folder and its contents with the same folder from somewhere else, except that in the event of a file-name collision I want to modify it so that it renames the new file (eg "myfile001") instead of overwiting with it.

Does anyone know of any freely available BASIC code please? I am using WinXP. Thanks 92.29.122.203 (talk) 15:17, 16 January 2011 (UTC)

:What BASIC interpreter are you using? This sort of thing would be much easier if you used something with a more robust file handling library, like VB's File System Object. If you use just BASIC, you'll have to re-invent the wheel a few times, because its file handling functions are pretty simple by comparison. --Mr.98 (talk) 15:21, 16 January 2011 (UTC)

I will use any Basic that is freely available. 2.97.211.3 (talk) 19:15, 16 January 2011 (UTC)

:Would you accept VBScript as a form of BASIC? There's a file handling example in the article which you can try out right now. Copy and paste into notepad, save it and rename it to end in .vbs (making sure you can see file extensions in general, so you don't get a hidden .txt after the .vbs). Then double click it to run. If this is the sort of thing you're looking for, I'm sure further hints for how to modify it to copy files will be forthcoming. 81.131.51.219 (talk) 00:24, 17 January 2011 (UTC)

Unfortunately VBScript would be too diffcult for me to be able to use myself. There are many other variants of basic, including those listed here: http://www.thefreecountry.com/compilers/basic.shtml The most difficult thing would be traversing all the sub-directories. Thanks 92.28.254.64 (talk) 00:40, 18 January 2011 (UTC)

SmallBASIC has a DIRWALK command, so assuming it can copy files I will have to figure out how to use that. 92.28.242.93 (talk) 13:51, 18 January 2011 (UTC)

Free video surveillance software.

My car has been broken in to 1 to many times, Id like to build a video surveillance system using my web cams and my extra computer. i have been looking for a free piece of software that fits my criteria, which is as follows:

  • Free.
  • Windows or linux based.
  • Time&date stamped video.
  • 24/7 video&audio recording.
  • Ability to delete old video after a set time, i.e. delete videos after 1 week.
  • supports my USB cameras at their full resolution (1280x1024).
  • record at more than 5fps.
  • ability to handle 3 cameras.
  • Ability to save video to an external drive.

If anyone knows any programs that fits my wish list please let me know. Only program that i have found that comes close is eyeline (records and 1/2 fps), and zoneminder (doesnt directly support my cameras). Please don't provide random links to webcam software that you found on Google. I know how to use Google. Please only include software that you definitely know has the feature mentioned above. kthxbai 98.208.63.16 (talk) 19:41, 16 January 2011 (UTC)

As a side note; id like to point out that i dont want motion detection based recording, it would be nice if this program would id when motion happened, but not base weather it records or not on motion. kthxbai 98.208.63.16 (talk) 20:02, 16 January 2011 (UTC)

:3 high-def usb cameras on one computer sounds iffy. The other stuff seems easy. Can you use 3 computers? It is pretty easy to scrounge old laptops these days. 67.122.209.190 (talk) 10:35, 17 January 2011 (UTC)

::GPhoto allows you to write command-line scripts (or compile your own programs, if you know how), and interface with almost any USB-enabled web camera. Using this tool, you could set up photo or video with whatever settings your camera(s) support. GPhoto has [http://www.gphoto.org/doc/ thorough documentation] so you can [http://www.gphoto.org/proj/libgphoto2/support.php check if your camera is supported]. Nimur (talk) 21:11, 17 January 2011 (UTC)

:::Try Cerberus, it seems specifically designed for this sort of stuff: www.freshney.org/cerberus/ 110.175.208.144 (talk) 04:11, 19 January 2011 (UTC)

Theoretically possible to browse iDevice file systems without jailbreak

Is it theoretically possible to browse the system partition of an iPhone, iPad, or iPod touch without jailbreaking? Say, for instance, a program that will simply ignore the access restrictions since the device would not be running? --Melab±1 22:58, 16 January 2011 (UTC)

:"Theoretically", every piece of stored information could be accessed or analyzed somehow. If the digital data is represented somewhere as digital data in an electronic circuit, something could strobe through and copy all of it; and then at worst, you'd have to decrypt it.

:In practice, though, you're kind of out of luck - let me explain why. "The device is off" is not quite an accurate description of the situation when your PC is connected to an iPod or iPhone. In reality, a chip (possibly the iPod's main CPU, or possibly a peripheral microcontroller only responsible for USB transfer) negotiates all data transactions with the USB host (your PC). USB protocol is quite complicated; briefly summarized, the iPod's controller sends a set of metadata that "publishes" all the standard USB features available. One of these features is a USB mass-storage device class - a software abstraction of a "hard-drive"-style block of data. There are many other software abstractions - sometimes the same data on the iPod is represented through multiple different USB classes (allowing you to access stored mp3 files through the proprietary interface, or to treat them as raw files, and so on). But in all cases, the transactions are mediated through the USB client controller (which runs software on the iPod and is out of your control - you can't "reprogram" it. (Well, "jailbreaking" might help - I'm not familiar enough with iPods to know whether jailbreak firmware also opens up the peripheral USB controller firmware, which may be entirely separate hardware). So if the USB client processor wants to deny access to anything, including the iPod's main flash memory or NVRAM or system area (or whatever other name they choose to call their proprietary nonvolatile storage), you're sort of out of luck. You'll have to (again) reverse-engineer their USB stack, re-program that controller (which may or may not be the main iPod CPU), and then you're free to access anything physically connected to the USB bus.

:Let me re-emphasize - all of this is possible - and you can bet that some engineer(s) at Apple know how to do it - but it is not currently realistic to reverse-engineer this stuff by brute-force. In my opinion, any "chance" jail-break by a "17-year-old Russian hacker" is a flimsy cover-story for software tools that got leaked by a disgruntled ex-Apple engineer. As yet, no "17-year-old Russian hacker" has yet "brute-force reverse-engineered" the iPod USB controller firmware. Nimur (talk) 17:04, 17 January 2011 (UTC)

::In closing, and at the risk of becoming a rant, let me just say: this is why your effort to reverse-engineer an iPod is futile. Just pick a more standard embedded development board. Sure, iPods are nice and small and the form-factor is cool; the screen is pretty nice; but otherwise, their functionality is equivalent to any other off-the-shelf hardware - only, the Apple electronics are designed by a team of skilled engineers so that they are extremely difficult to modify. They use non-standard pin-outs, non-standard cable connectors, non-standard software, and so on. If you want to work on those electronics, you essentially need to be working inside the Apple development shop in Cupertino - with their specific software and hardware tools, domain-expertise, and so forth. Other commercial hardware is just as good as an iPod's - but doesn't try to road-block "unofficial" developers at every other step. Nimur (talk) 17:10, 17 January 2011 (UTC)

::Well, I was talking about iOS devices (i.e., the iPad, the iPhone, and the iPod touch). I believe that normal iPods can be browsed in their entirety. The thing with iOS devices is that software like iPhone Browser or Phone Disk can access the "media" partition. The NAND chip is what contains the media partition and also contains the root partition which I think contains the preloaded apps, such as Notes and Mail, and all of the system files. In the case that someone does jailbreak their iOS, they have full read/write access to the root partition. So with this mind I am wondering if gaining access to the iOS device's root partition could be possible by writing a program that ignores file permissions. --Melab±1 22:21, 17 January 2011 (UTC)

:::And all this would be using the cable that comes with the iOS device. --Melab±1 22:22, 17 January 2011 (UTC)

::::Let me rephrase more succinctly: when you connect via the default cable, your computer is communicating with a USB Client processor on the device - not directly accessing the NAND chip. Any file permissions are enforced by the USB client (on the device) - so to "override" those permissions, you need to reprogram the device's USB controller. That may also require reprogramming the device's main CPU. Here are the official [http://www.usb.org/developers/docs/ USB specification documents] if you want to try to implement or reverse-engineer the device's communication protocol. Keep in mind that additional software protocols ride on top of that layer: here's [http://www.theiphonewiki.com/wiki/index.php?title=AFC information on Apple File Connect service], including an "afc2" replacement service that seems to be used by jailbreakers. That information looks out-of-date, though. If the USB controller denies you access to hardware at the protocol level, no amount of "software workaround" will permit access. Nimur (talk) 23:30, 17 January 2011 (UTC)

:::::That doesn't explain why jailbreaks can work than. I know that it sounds like I'm doing a 180°, but I'm not. --Melab±1 20:58, 19 January 2011 (UTC)

::::::I don't really know what "jailbreaking" is with a high degree of certainty. As I understand it, "jailbreaking" an iPhone doesn't actually replace any firmware; it only involves using software to ignore certain iOS software-imposed file- and memory- access permissions. I defer to the more informative [http://www.theiphonewiki.com/wiki/index.php?title=Main_Page "theiphonewiki"] website, which seems to have some technical details. Again, if the hardware enforces restrictions, you can't override them through software. Nimur (talk) 01:09, 20 January 2011 (UTC)