MCPcopy Create free account
hub / github.com/davisking/dlib / thread_proc

Method thread_proc

dlib/test/sockets.cpp:134–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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";

Callers

nothing calls this directly

Calls 9

close_gracefullyFunction · 0.85
writeMethod · 0.80
get_local_hostnameFunction · 0.50
hostname_to_ipFunction · 0.50
create_connectionFunction · 0.50
waitMethod · 0.45
clearMethod · 0.45
get_listening_portMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected