java.net.ProtocolFamily Class in Java Last Updated : 16 Nov, 2021 Comments Improve Suggest changes Like Article Like Report ProtocolFamily is a java Interface. The java.net.ProtocolFamily represents a family of communication protocols. Java.net.StandardProtocolFamily implements ProtocolFamily Interface. public interface ProtocolFamily Methods of java.net.ProtocolFamily java.net.ProtocolFamily interface contains only one method: S.No. Method Description Return Type 1.name()name() method returns the name of the protocol familyStringUse of ProtocolFamily InterfaceS.No.Package Modifier and TypeName Description1.java.netclassStandardProtocolFamilyStandardProtocolFamily class defines the standard families of communication protocols.2.java.nio.channelsstatic DatagramChannel DatagramChannel.open(ProtocolFamily family)DatagramChannel.open() static method opens a datagram channel.3.java.nio.channels.spiabstract DatagramChannelSelectorProvider.openDatagramChannel( ProtocolFamily family)SelectorProvider.openDatagramChannel Opens a datagram channel. Java Program for Better Understanding of the ProtocolFamily Interface Java // Java Program to get Protocol // family for an IP Address // import Guava library import com.google.common.net.InetAddresses; import java.io.*; import java.net.*; class GFG { public static void main(String[] args) { try { // to get the ip address of InetAddress ip = InetAddress.getByName("45.22.30.39"); System.out.println("Host Name is " + ip.getHostName()); // getProtocolFamily() will check and return the // protocol family of the given IP ProtocolFamily protocolFamily = getProtocolFamily(ip); System.out.println("Protocol family of the " + ip.getHostName() + " is " + protocolFamily); } catch (Exception e) { System.out.println("Some exception" + e.getMessage()); } } public static ProtocolFamily getProtocolFamily(InetAddress inetAddress) { // to check if address is valid or not if (InetAddresses.isInetAddress( inetAddress.getHostName())) { // if address is valid // will return the protocol family of the // address return StandardProtocolFamily.INET; } else { // address is not valid System.out.println( "Address " + inetAddress + "is invalid hence can't determine the protocol family"); } return StandardProtocolFamily.INET; } } OutputHost Name is 45.22.30.39 Protocol family of the 45.22.30.39 is INET Comment More infoAdvertise with us H harshsethi2000 Follow Improve Article Tags : Java Java-Classes Java-net-package Practice Tags : Java Explore BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOPs & InterfacesClasses and Objects in Java10 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial15+ min readSynchronization in Java10 min readFile Handling in Java5 min readJava Method References9 min readJava 8 Stream Tutorial15+ min readJava Networking15+ min readJDBC Tutorial12 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions7 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like