How can I tell the UNO to give up if it can't send a I2c wire transmission?

I have an UNO sending data to a Mega over I2c. I noticed that, if the Mega isn't plugged in, the UNO will get stuck at the "Wire.beginTransmission (SLAVE_ADDRESS);" line until the Mega is plugged in. Is there a way I can tell the UNO to give up after a few seconds and move on to the rest of the script?

Wire.beginTransmission (SLAVE_ADDRESS);
    I2C_writeAnything (integer);
    Wire.endTransmission ();

Thanks!

The wire library, it seems, does not do that.

It might be possible to set up a timer interrupt, somehow. Use longjmp so that when the interrupt returns, it returns back to the longjmp location. It's beyond me, unfortunately.

I have trouble believing this claim, because beginTransmission doesn't actually transmit anything, and thus can't fail if there is no device at the other end.

I could - sort of - believe it about endTransmission, however if no device is plugged in, it will (effectively) return a NAK which you can detect. Maybe post all your code?

http://snippets-r-us.com/