It's safe, but virtually impossible to glue live rock. Use superglue gel like reefnutz says, but it's best used for glueing small items like coral frags.
the part im struggling with is when glueing the rock should be dry. if so how does one dry the rock and glue the coral without exposing to air for a lengthy period of time? or isn't it long enough to really matter?
I dry the rock off and take the frag out of the water and glue it up. I leave the frag/rock out for at least a full minute. Sometimes I use a pipette to wet the frag while the glue dries. It dries pretty fast.
I just glue underwater. I usually dry the end of the frag on my shirt put on a glob of gel and stick it in its place underwater. A few seconds after placing it moving it and twisting it a bit helps make a tighter bond.