A geek-seeking missle

Thoughts of a random geek

Tuesday, November 18, 2008

Windows Sockets

MSDN on winsock

CodeProject C++ skeleton using winsock

Of note: An application must call the WSACleanup function for every successful time the WSAStartup function is called. This means, for example, that if an application calls WSAStartup three times, it must call WSACleanup three times. The first two calls to WSACleanup do nothing except decrement an internal counter; the final WSACleanup call for the task does all necessary resource deallocation for the task.

Also: If you include windows.h and winsock2.h, you have to put winsock2 first. Otherwise, windows.h will include winsock.h and you'll get a plethora of redefinition errors from winsock2.h.

Inter-process communication in Windows

MSDN on the many ways to do IPC, including links to each.

Abridged version -
  • memory mapped files are fast, but need wrapped in a mutex and can't be used over a network
  • WM_COPYDATA message is useful if you have a message pump. Windows automagically shares the address space for you.
  • Mailslots can broadcast to multiple receiving processes and work on a network
  • Pipes are guaranteed two-way communication and work over a network
  • Sockets are platform independent

There's more, but I don't have experience with DDE/COM.

Here's an awesome codeproject page discussing multiple ways to inject your code into another process, including how to subclass a control (like the Windows Start button, in the example it switches the left and right mouse buttons). The page is extremely informative and uses some IPC techniques.

Monday, November 10, 2008

High-precision timing in Windows, cont.

Building on what I found earlier, here are some more attempts to make a high precision, high accuracy, high performance timer in Windows.

This link explains another timer, and provides BSD-licensed code.

ByteFusion makes a proprietary timer.

SourceForge has a project called fasttime, but it doesn't support Windows.

Fasttime has a sister project, TSC-I2, which has some nice details.

Here is the documentation for the Windows NTP client, w32tm, the Windows Time Service.

An MSDN blog indicates that the Windows Time Service is intended to keep sync only to the extent that Kerberos requires, and cannot maintain sync down to the second boundary.

Friday, October 31, 2008

Android FTW

his is why I've been waiting for Android. I don't care how good or bad the phone is. I want to write programs for my cell phone. And I'm not the only one. There are MANY developers all over the world who have itches they want to scratch. Give them the power and you will see amazing things.


Take a picture of a barcode and the phone automatically looks for a better price online and in brick-and-mortar stores. It can show you which stores are closer to you, so you can get the best price/distance.

http://blogs.dailynews.com/bargain/2008/10/google-phone-finds-the-best-pr.html



Somebody already made my location-aware ringer. It's called Locale.

One project named GeoLife gives users a way to set to-do lists and get reminders on their phones. Walk by the market, and the device might buzz with a message that you're supposed to pick up milk. Another effort, named Flare, was designed to help small businesses like pizza shops cheaply track their drivers.

Then there was Locale, which lets users configure their phones to automatically adjust their settings when the devices detect themselves in certain zones. So you might set your phone to automatically go into vibrate mode in the office and silent mode at the movie theater, and ring everywhere else.

The other student projects included Re:Public, a social-networking program that helps people make new friends in their area. Loco offers a way to find events around town and invite other people. Snap guides users to interesting places in their vicinity.

And there was KEI, pronounced "key," because that's what it is: software that enables a cell phone to unlock your car. It was the lone entrant not to tap the location craze.


http://www.msnbc.msn.com/id/24582069/

Wednesday, October 29, 2008

10/29/1675 - Liebniz sums it all up

Gottfried Leibniz was a many of many talents. The number of fields he was interested in was quite vast. While you might thank Newton for the calculus, it turns out Leibniz worked with Newton for a while. In fact, it is Leibniz's notation, with the integral sign and the differential, which we use today. Wired has a nice summary of Leibniz up today.

Friday, October 24, 2008

Time Reversal and Frequency Response

Someone on comp.dsp wrote a paper about time reversal and the effect on frequency response (PDF). It's interesting and doesn't require expertise in mathematics, but it does expect you to understand calculus. Basically, the magnitude is the same but the phase is negated, and in the discrete case there's also a time-domain right-shift that creates a frequency-dependent term in the phase.