diff options
Diffstat (limited to 'libjava/gnu/java/net/natPlainSocketImplWin32.cc')
-rw-r--r-- | libjava/gnu/java/net/natPlainSocketImplWin32.cc | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/libjava/gnu/java/net/natPlainSocketImplWin32.cc b/libjava/gnu/java/net/natPlainSocketImplWin32.cc index 57607e85696..411acfa023a 100644 --- a/libjava/gnu/java/net/natPlainSocketImplWin32.cc +++ b/libjava/gnu/java/net/natPlainSocketImplWin32.cc @@ -54,9 +54,9 @@ gnu::java::net::PlainSocketImpl::create (jboolean stream) _Jv_platform_close_on_exec (sock); - // We use fnum in place of fd here. From leaving fd null we avoid + // We use native_fd in place of fd here. From leaving fd null we avoid // the double close problem in FileDescriptor.finalize. - fnum = sock; + native_fd = sock; } void @@ -94,16 +94,16 @@ gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *host, jint lpor throw new ::java::net::SocketException (JvNewStringUTF ("invalid length")); // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT. - ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i)); + ::setsockopt(native_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i)); - if (::bind (fnum, ptr, len) != SOCKET_ERROR) + if (::bind (native_fd, ptr, len) != SOCKET_ERROR) { address = host; socklen_t addrlen = sizeof(u); if (lport != 0) localport = lport; - else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR) + else if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != SOCKET_ERROR) localport = ntohs (u.address.sin_port); else goto error; @@ -165,10 +165,10 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr, if (timeout > 0) { // FIXME: we're creating a fresh WSAEVENT for each connect(). - WSAEventWrapper aWSAEventWrapper(fnum, FD_CONNECT); + WSAEventWrapper aWSAEventWrapper(native_fd, FD_CONNECT); WSAEVENT hEvent = aWSAEventWrapper.getEventHandle (); - if (::connect (fnum, ptr, len) == SOCKET_ERROR) + if (::connect (native_fd, ptr, len) == SOCKET_ERROR) { if (WSAGetLastError () != WSAEWOULDBLOCK) throwConnectException (); @@ -189,7 +189,7 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr, // connect() succeeded. Use any socket-specific error code // instead of the thread-based one. int nErrCode; int nErrLen=sizeof(nErrCode); - if (::getsockopt(fnum, SOL_SOCKET, SO_ERROR, (char*) &nErrCode, + if (::getsockopt(native_fd, SOL_SOCKET, SO_ERROR, (char*) &nErrCode, &nErrLen) == SOCKET_ERROR) { throwConnectException (); @@ -203,7 +203,7 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr, } else { - if (::connect (fnum, ptr, len) == SOCKET_ERROR) + if (::connect (native_fd, ptr, len) == SOCKET_ERROR) throwConnectException(); } @@ -213,7 +213,7 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr, // A bind may not have been done on this socket; if so, set localport now. if (localport == 0) { - if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR) + if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) != SOCKET_ERROR) localport = ntohs (u.address.sin_port); else throwConnectException(); @@ -223,7 +223,7 @@ gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr, void gnu::java::net::PlainSocketImpl::listen (jint backlog) { - if (::listen (fnum, backlog) == SOCKET_ERROR) + if (::listen (native_fd, backlog) == SOCKET_ERROR) { _Jv_ThrowIOException (); } @@ -239,15 +239,15 @@ gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s) if (timeout > 0) { // FIXME: we're creating a fresh WSAEVENT for each accept(). - // One possible alternative would be that fnum really points + // One possible alternative would be that native_fd really points // to an extended structure consisting of the SOCKET, its // associated WSAEVENT, etc. - WSAEventWrapper aWSAEventWrapper(fnum, FD_ACCEPT); + WSAEventWrapper aWSAEventWrapper(native_fd, FD_ACCEPT); WSAEVENT hEvent = aWSAEventWrapper.getEventHandle (); for (;;) { - new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen); + new_socket = ::accept (native_fd, (sockaddr*) &u, &addrlen); if (new_socket != int(INVALID_SOCKET)) { @@ -285,7 +285,7 @@ gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s) } else { - new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen); + new_socket = ::accept (native_fd, (sockaddr*) &u, &addrlen); } if (new_socket == int(INVALID_SOCKET)) @@ -312,7 +312,7 @@ gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s) else throw new ::java::net::SocketException (JvNewStringUTF ("invalid family")); - s->fnum = new_socket; + s->native_fd = new_socket; s->localport = localport; s->address = new ::java::net::InetAddress (raddr, NULL); s->port = rport; @@ -330,7 +330,7 @@ gnu::java::net::PlainSocketImpl::close() JvSynchronize sync (this); // should we use shutdown here? how would that effect so_linger? - int res = ::closesocket (fnum); + int res = ::closesocket (native_fd); if (res == -1) { @@ -342,7 +342,7 @@ gnu::java::net::PlainSocketImpl::close() _Jv_ThrowIOException (); } // Safe place to reset the file pointer. - fnum = -1; + native_fd = -1; timeout = 0; } @@ -355,7 +355,7 @@ gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jint b) while (r != 1) { - r = ::send (this$0->fnum, (char*) &d, 1, 0); + r = ::send (this$0->native_fd, (char*) &d, 1, 0); if (r == -1) { DWORD dwErr = WSAGetLastError(); @@ -390,7 +390,7 @@ gnu::java::net::PlainSocketImpl$SocketOutputStream::write(jbyteArray b, int written = 0; while (len > 0) { - int r = ::send (this$0->fnum, (char*) bytes, len, 0); + int r = ::send (this$0->native_fd, (char*) bytes, len, 0); if (r == -1) { @@ -425,7 +425,7 @@ gnu::java::net::PlainSocketImpl::sendUrgentData (jint) // read() helper static jint -doRead(int fnum, void* buf, int count, int timeout) +doRead(int native_fd, void* buf, int count, int timeout) { int r = 0; DWORD dwErrorCode = 0; @@ -438,7 +438,7 @@ doRead(int fnum, void* buf, int count, int timeout) // gone from a non-zero to zero timeout. What we'd // really need is a member state variable in addition // to timeout - int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO, + int nRet= ::setsockopt(native_fd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)); if (nRet != NO_ERROR) { @@ -446,7 +446,7 @@ doRead(int fnum, void* buf, int count, int timeout) goto error; } - r = ::recv (fnum, (char*) buf, count, 0); + r = ::recv (native_fd, (char*) buf, count, 0); if (r == 0) return -1; @@ -485,7 +485,7 @@ jint gnu::java::net::PlainSocketImpl$SocketInputStream::read(void) { jbyte b; - doRead(this$0->fnum, &b, 1, this$0->timeout); + doRead(this$0->native_fd, &b, 1, this$0->timeout); return b & 0xFF; } @@ -505,7 +505,7 @@ gnu::java::net::PlainSocketImpl$SocketInputStream::read(jbyteArray buffer, jbyte *bytes = elements (buffer) + offset; // Read the socket. - return doRead(this$0->fnum, bytes, count, this$0->timeout); + return doRead(this$0->native_fd, bytes, count, this$0->timeout); } // How many bytes are available? @@ -514,7 +514,7 @@ gnu::java::net::PlainSocketImpl::available(void) { unsigned long num = 0; - if (::ioctlsocket (fnum, FIONREAD, &num) == SOCKET_ERROR) + if (::ioctlsocket (native_fd, FIONREAD, &num) == SOCKET_ERROR) _Jv_ThrowIOException (); return (jint) num; @@ -526,7 +526,7 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va int val; socklen_t val_len = sizeof (val); - if (fnum < 0) + if (native_fd < 0) throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed")); if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$)) @@ -558,13 +558,13 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va switch (optID) { case _Jv_TCP_NODELAY_ : - if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val, + if (::setsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val, val_len) == SOCKET_ERROR) goto error; return; case _Jv_SO_KEEPALIVE_ : - if (::setsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val, + if (::setsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val, val_len) == SOCKET_ERROR) goto error; break; @@ -575,7 +575,7 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va break; case _Jv_SO_OOBINLINE_ : - if (::setsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val, + if (::setsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val, val_len) == SOCKET_ERROR) goto error; break; @@ -585,7 +585,7 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va l_val.l_onoff = (val != -1); l_val.l_linger = val; - if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val, + if (::setsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val, sizeof(l_val)) == SOCKET_ERROR) goto error; return; @@ -594,7 +594,7 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va case _Jv_SO_RCVBUF_ : int opt; optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF; - if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, + if (::setsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, val_len) == SOCKET_ERROR) goto error; return; @@ -620,7 +620,7 @@ gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *va break; case _Jv_IP_TOS_ : - if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val, + if (::setsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val, val_len) == SOCKET_ERROR) goto error; break; @@ -655,7 +655,7 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) switch (optID) { case _Jv_TCP_NODELAY_ : - if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val, + if (::getsockopt (native_fd, IPPROTO_TCP, TCP_NODELAY, (char *) &val, &val_len) == SOCKET_ERROR) goto error; else @@ -663,7 +663,7 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) break; case _Jv_SO_LINGER_ : - if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val, + if (::getsockopt (native_fd, SOL_SOCKET, SO_LINGER, (char *) &l_val, &l_val_len) == SOCKET_ERROR) goto error; @@ -674,20 +674,20 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) break; case _Jv_SO_KEEPALIVE_ : - if (::getsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val, + if (::getsockopt (native_fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &val, &val_len) == SOCKET_ERROR) goto error; else return new ::java::lang::Boolean (val != 0); case _Jv_SO_BROADCAST_ : - if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val, + if (::getsockopt (native_fd, SOL_SOCKET, SO_BROADCAST, (char *) &val, &val_len) == SOCKET_ERROR) goto error; return new ::java::lang::Boolean ((jboolean)val); case _Jv_SO_OOBINLINE_ : - if (::getsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val, + if (::getsockopt (native_fd, SOL_SOCKET, SO_OOBINLINE, (char *) &val, &val_len) == SOCKET_ERROR) goto error; return new ::java::lang::Boolean ((jboolean)val); @@ -696,7 +696,7 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) case _Jv_SO_SNDBUF_ : int opt; optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF; - if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, + if (::getsockopt (native_fd, SOL_SOCKET, opt, (char *) &val, &val_len) == SOCKET_ERROR) goto error; else @@ -708,7 +708,7 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) { jbyteArray laddr; - if (::getsockname (fnum, (sockaddr*) &u, + if (::getsockname (native_fd, (sockaddr*) &u, &addrlen) == SOCKET_ERROR) goto error; @@ -748,7 +748,7 @@ gnu::java::net::PlainSocketImpl::getOption (jint optID) break; case _Jv_IP_TOS_ : - if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val, + if (::getsockopt (native_fd, SOL_SOCKET, IP_TOS, (char *) &val, &val_len) == SOCKET_ERROR) goto error; return new ::java::lang::Integer (val); @@ -776,13 +776,13 @@ error: void gnu::java::net::PlainSocketImpl::shutdownInput (void) { - if (::shutdown (fnum, 0)) + if (::shutdown (native_fd, 0)) _Jv_ThrowSocketException (); } void gnu::java::net::PlainSocketImpl::shutdownOutput (void) { - if (::shutdown (fnum, 1)) + if (::shutdown (native_fd, 1)) _Jv_ThrowSocketException (); } |