+#define MASK_SIGNAL() \
+{ \
+ void (*old_handler)(int); \
+\
+ old_handler = signal(SIGPIPE, SIG_IGN);
+
+#define UNMASK_SIGNAL() \
+ signal(SIGPIPE, old_handler); \
+}
+
+#define ENABLE_TIMEOUT(socket) \
+{ \
+ struct itimerval old_ival, new_ival; \
+ void (*old_timer_sig)(int); \
+\
+ old_timer_sig = signal(SIGALRM, SIG_DFL); \
+ siginterrupt(SIGALRM, 1); \
+ new_ival.it_value.tv_sec = socket->m_timeout / 1000; \
+ new_ival.it_value.tv_usec = (socket->m_timeout % 1000) * 1000; \
+ new_ival.it_interval.tv_sec = 0; \
+ new_ival.it_interval.tv_usec = 0; \
+ setitimer(ITIMER_REAL, &new_ival, &old_ival);
+
+#define DISABLE_TIMEOUT(socket) \
+ signal(SIGALRM, old_timer_sig); \
+ siginterrupt(SIGALRM, 0); \
+ setitimer(ITIMER_REAL, &old_ival, NULL); \
+}
+