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

Computing desk
< January 15 << Dec | January | Feb >> January 17 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 16 edit

How to keep sockets alive in Java edit

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)[reply]

Could you specify some versions?Smallman12q (talk) 05:08, 16 January 2011 (UTC)[reply]
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)[reply]
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 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)[reply]
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)[reply]

The application was unable.. edit

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)[reply]

  • 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)[reply]

iPhone to monitor streaming edit

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)[reply]

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)[reply]

Find word and beep edit

  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)[reply]

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)[reply]

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

electronics (ripple) edit

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)[reply]

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)[reply]

Seeking Basic program code to copy folders and files edit

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)[reply]

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)[reply]

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

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)[reply]

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)[reply]

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)[reply]

insert copyright into a digital photo edit

How can I insert copyright information into a digital photo file? Bubba73 You talkin' to me? 17:05, 16 January 2011 (UTC)[reply]

Depends what you would like to do - do you want any inscription to be visible in the photo, or do you want to add a copyright notice to the metadata of the file (the EXIF information)? --Ouro (blah blah) 17:51, 16 January 2011 (UTC)[reply]
Are you asking about a digital watermark? If so, most advanced image manipulation programs (such as Photoshop) should have a "watermark" function. -- 174.21.229.4 (talk) 19:52, 16 January 2011 (UTC)[reply]
I do not want it to be visible over the photo, so I want to put it in the metadata. I have Photoshop Elements version 6, but I couldn't find how to alter the metadata. (But that is when I was looking for "copyright".) Bubba73 You talkin' to me? 22:41, 16 January 2011 (UTC)[reply]
I hope you appreciate that it is a simple matter for someone to modify the metadata or remove it completely? Astronaut (talk) 23:19, 16 January 2011 (UTC)[reply]
I thought it might be. Bubba73 You talkin' to me? 02:11, 17 January 2011 (UTC)[reply]
You can alter the metadata in Windows XP in the windows explorer, if you right click the file and select properties summary advanced, scroll down to comments, keywords section, you can click on the value part and change this. Graeme Bartlett (talk) 04:13, 17 January 2011 (UTC)[reply]
If what you are looking for is secure digital rights management software — e.g., an electronic "lock" that will keep people from using your photo in ways you don't want them to — well, it doesn't exist at this point, and might never. (The only things which have the slightest chance of enforcing said restrictions are devices where they are hard-wired into them, like iPads and Kindles and things like that. But general purpose computers will probably always be capable of evading such things.) You have basically three options. One is to write your copyright info on the photo itself in an obnoxious way that will at least make it obvious to everyone (e.g. with a visible watermark). It detracts from the photo that way, but is hard to get rid of. You can write our copyright info on the photo in a hidden way (with a digital watermark or in the EXIF data) but that won't really stop anyone from doing anything with it. The third and perhaps more standard way is to put your website info on the photo at the bottom in a way that is not so ugly that whomever will use it will just snip it off. Then you only distribute a relatively low-resolution version of the photo — one that would look OK on the screen, but not in print. Then you just hope that if people do distribute it around, at least you'll get credit for it, and if someone actually wants it for a purpose that could bring revenue back to you, they'll feel obligated to get in touch for the higher resolution version. If your only goal is controlling how it is used (and not, say, making sure you get credit or driving revenue), then you'd better not put it on the internet at all. There are ways to try and make it harder for people to download, but all you have to do is take a screenshot and those are completely subverted (and believe me, I do that kind of thing all of the time, myself!). --Mr.98 (talk) 14:54, 17 January 2011 (UTC)[reply]
If you don't want it to be visible on the image, you should put it in the metadata. People can then edit it, but it will still be copyrighted. The way to edit metadata depends on the type of file you are working with. If it is a Jpeg file, the metadata is usually in the form called EXIF, which you can read and alter in PhotoShop, or, as mentioned above, even in Windows Explorer. If you want to hide evidence of the copyright inside the file, you may have to explore a technique along the lines of digital steganography. Looie496 (talk) 18:03, 17 January 2011 (UTC)[reply]
I have Photoshop Elements 6, but I can't figure out how to edit the data. It is a TIF file, though. Bubba73 You talkin' to me? 20:03, 18 January 2011 (UTC)[reply]
I don't see how to do it in Windows Explorer either (i.e. right-click on the file name.) Bubba73 You talkin' to me? 20:07, 18 January 2011 (UTC)[reply]
OK, actually it is Properties/Summary/Simple (not advanced). Bubba73 You talkin' to me? 02:44, 19 January 2011 (UTC)[reply]
Windows will allow those changes to a JPEG file but not a TIF - it says access denied, etc. Bubba73 You talkin' to me? 02:51, 19 January 2011 (UTC)[reply]

Free video surveillance software. edit

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)[reply]

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)[reply]

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)[reply]
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 thorough documentation so you can check if your camera is supported. Nimur (talk) 21:11, 17 January 2011 (UTC)[reply]
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)[reply]

Theoretically possible to browse iDevice file systems without jailbreak edit

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)[reply]

"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)[reply]
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)[reply]
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)[reply]
And all this would be using the cable that comes with the iOS device. --Melab±1 22:22, 17 January 2011 (UTC)[reply]
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 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 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)[reply]
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)[reply]
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 "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)[reply]