| 132 | } |
| 133 | |
| 134 | void thread_proc ( |
| 135 | ) |
| 136 | { |
| 137 | try |
| 138 | { |
| 139 | dlog << LTRACE << "enter thread"; |
| 140 | { |
| 141 | auto_mutex M(gm); |
| 142 | while (assigned_port == 0) |
| 143 | gs.wait(); |
| 144 | } |
| 145 | |
| 146 | int status; |
| 147 | std::unique_ptr<connection> con; |
| 148 | string hostname; |
| 149 | string ip; |
| 150 | status = get_local_hostname(hostname); |
| 151 | if (status) |
| 152 | { |
| 153 | srv.tag = 1.0; |
| 154 | srv.error_occurred = true; |
| 155 | srv.clear(); |
| 156 | dlog << LERROR << "leaving thread, line: " << __LINE__; |
| 157 | dlog << LERROR << "get_local_hostname() failed"; |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | status = hostname_to_ip(hostname,ip); |
| 162 | if (status) |
| 163 | { |
| 164 | srv.tag = 2.0; |
| 165 | srv.error_occurred = true; |
| 166 | srv.clear(); |
| 167 | dlog << LERROR << "leaving thread, line: " << __LINE__; |
| 168 | dlog << LERROR << "hostname_to_ip() failed"; |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | dlog << LTRACE << "try to connect to the server at port " << srv.get_listening_port(); |
| 173 | status = create_connection(con,srv.get_listening_port(),ip); |
| 174 | if (status) |
| 175 | { |
| 176 | srv.tag = 3.0; |
| 177 | srv.error_occurred = true; |
| 178 | srv.clear(); |
| 179 | dlog << LERROR << "leaving thread, line: " << __LINE__; |
| 180 | dlog << LERROR << "create_connection() failed"; |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | dlog << LTRACE << "sending magic_num to server"; |
| 185 | int i; |
| 186 | for (i = 0; i < min_bytes_sent; ++i) |
| 187 | { |
| 188 | con->write(&magic_num,1); |
| 189 | } |
| 190 | |
| 191 | dlog << LTRACE << "shutting down connection to server"; |
nothing calls this directly
no test coverage detected