diff --git a/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c b/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c index 78dd70428ec..f35b6fb6535 100644 --- a/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c +++ b/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -189,11 +189,9 @@ int dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value) { if (cmd == TCP_NODELAY) { - struct protoent *proto = getprotobyname("TCP"); - int tcp_level = (proto == 0 ? IPPROTO_TCP: proto->p_proto); uint32_t onl = (uint32_t)on; - if (setsockopt(fd, tcp_level, TCP_NODELAY, + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&onl, sizeof(uint32_t)) < 0) { return SYS_ERR; } diff --git a/src/jdk.jdwp.agent/windows/native/libdt_socket/socket_md.c b/src/jdk.jdwp.agent/windows/native/libdt_socket/socket_md.c index f99112a5fb0..b3a9e77b1bb 100644 --- a/src/jdk.jdwp.agent/windows/native/libdt_socket/socket_md.c +++ b/src/jdk.jdwp.agent/windows/native/libdt_socket/socket_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -268,11 +268,9 @@ int dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value) { if (cmd == TCP_NODELAY) { - struct protoent *proto = getprotobyname("TCP"); - int tcp_level = (proto == 0 ? IPPROTO_TCP: proto->p_proto); long onl = (long)on; - if (setsockopt(fd, tcp_level, TCP_NODELAY, + if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&onl, sizeof(long)) < 0) { return SYS_ERR; }