- if(sock < 0) {
- logger(LOG_ERR, _("System call `%s' failed: %s"), "socket", strerror(errno));
- return false;
- }
-
- if(bind(sock, ai->ai_addr, ai->ai_addrlen)) {
- logger(LOG_ERR, _("System call `%s' failed: %s"), "bind", strerror(errno));
- return false;
- }
-
- freeaddrinfo(ai);
-
- if(listen(sock, 1)) {
- logger(LOG_ERR, _("System call `%s' failed: %s"), "listen", strerror(errno));
- return false;
- }
-
- /* Start the tap reader */
-
- thread = CreateThread(NULL, 0, tapreader, NULL, 0, NULL);
-
- if(!thread) {
- logger(LOG_ERR, _("System call `%s' failed: %s"), "CreateThread", winerror(GetLastError()));
- return false;
- }
-
- /* Wait for the tap reader to connect back to us */
-
- if((device_fd = accept(sock, NULL, 0)) == -1) {
- logger(LOG_ERR, _("System call `%s' failed: %s"), "accept", strerror(errno));
- return false;
- }
-
- closesocket(sock);
-
- /* Set media status for newer TAP-Win32 devices */
-
- status = true;
- DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL);
-
- device_info = _("Windows tap device");
-
- logger(LOG_INFO, _("%s (%s) is a %s"), device, iface, device_info);