The Windows socket API only accepts socket file descriptors, not pipe descriptors or others. Thus, to implement Selector.wakeup(), we make a socket connection via the loopback interface and use it as a pipe.
| 728 | // Selector.wakeup(), we make a socket connection via the loopback |
| 729 | // interface and use it as a pipe. |
| 730 | Pipe(JNIEnv* e) : connected_(false), listener_(-1), reader_(-1), writer_(-1) |
| 731 | { |
| 732 | sockaddr_in address; |
| 733 | address.sin_family = AF_INET; |
| 734 | address.sin_port = 0; |
| 735 | address.sin_addr.s_addr = inet_addr("127.0.0.1"); // INADDR_LOOPBACK; |
| 736 | |
| 737 | listener_ = makeSocket(e); |
| 738 | if (e->ExceptionCheck()) |
| 739 | return; |
| 740 | |
| 741 | setBlocking(e, listener_, false); |
| 742 | |
| 743 | ::doBind(e, listener_, &address); |
| 744 | if (e->ExceptionCheck()) |
| 745 | return; |
| 746 | |
| 747 | ::doListen(e, listener_); |
| 748 | if (e->ExceptionCheck()) |
| 749 | return; |
| 750 | |
| 751 | socklen_t length = sizeof(sockaddr_in); |
| 752 | int r = getsockname( |
| 753 | listener_, reinterpret_cast<sockaddr*>(&address), &length); |
| 754 | if (r) { |
| 755 | throwIOException(e); |
| 756 | return; |
| 757 | } |
| 758 | |
| 759 | writer_ = makeSocket(e); |
| 760 | if (e->ExceptionCheck()) |
| 761 | return; |
| 762 | |
| 763 | setBlocking(e, writer_, true); |
| 764 | connected_ = ::doConnect(e, writer_, &address); |
| 765 | } |
| 766 | |
| 767 | void dispose() |
| 768 | { |
nothing calls this directly
no test coverage detected