| 107 | } |
| 108 | |
| 109 | void ipc_client::wait(void) |
| 110 | { |
| 111 | if (closing_) { |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | // ͬ��������Ϣ |
| 116 | if (sync_stream_) { |
| 117 | MSG_HDR hdr; |
| 118 | int n; |
| 119 | n = sync_stream_->read(&hdr, sizeof(hdr)); |
| 120 | if (n < 0) { |
| 121 | close(); |
| 122 | return; |
| 123 | } |
| 124 | if ((n = hdr.dlen) <= 0) { |
| 125 | trigger(hdr.nMsg, NULL, 0); |
| 126 | return; |
| 127 | } |
| 128 | string buf(n); |
| 129 | |
| 130 | if (sync_stream_->read(buf.c_str(), n) < 0) { |
| 131 | close(); |
| 132 | return; |
| 133 | } |
| 134 | trigger(hdr.nMsg, buf.c_str(), n); |
| 135 | } |
| 136 | |
| 137 | // �첽������Ϣ |
| 138 | else if (async_stream_) { |
| 139 | // �����첽����Ϣ���� |
| 140 | status_ = IO_WAIT_HDR; |
| 141 | async_stream_->read(sizeof(MSG_HDR)); |
| 142 | } |
| 143 | |
| 144 | // δ֪��� |
| 145 | else { |
| 146 | acl_assert(0); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void ipc_client::close(void) |
| 151 | { |