Java net socket address

Java net socket address

Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.

Uses of SocketAddress in com.sun.nio.sctp

Returns the source socket address if the message has been received, otherwise the preferred destination of the message to be sent.

Returns all of the remote addresses to which the given association on this channel’s socket is connected.

Uses of SocketAddress in java.net

This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname.

Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

Constructs a datagram packet for sending packets of length length with offset ioffset to the specified port number on the specified host.

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

Uses of SocketAddress in java.nio.channels

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Class InetSocketAddress

This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname. If resolution fails then the address is said to be unresolved but can still be used on some circumstances like connecting through a proxy.

Читайте также:  Javascript ios что это

It provides an immutable object used by sockets for binding, connecting, or as returned values.

The wildcard is a special local IP address. It usually means «any» and can only be used for bind operations.

Constructor Summary

Creates a socket address where the IP address is the wildcard address and the port number a specified value.

Method Summary

Returns the hostname, or the String form of the address if it doesn’t have a hostname (it was created using a literal).

Methods declared in class java.lang.Object

Constructor Details

InetSocketAddress

Creates a socket address where the IP address is the wildcard address and the port number a specified value. A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.

InetSocketAddress

Creates a socket address from an IP address and a port number. A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation. A null address will assign the wildcard address.

InetSocketAddress

Creates a socket address from a hostname and a port number. An attempt will be made to resolve the hostname into an InetAddress. If that attempt fails, the address will be flagged as unresolved. If there is a security manager, its checkConnect method is called with the host name as its argument to check the permission to resolve it. This could result in a SecurityException. A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.

Method Details

createUnresolved

Creates an unresolved socket address from a hostname and a port number. No attempt will be made to resolve the hostname into an InetAddress. The address will be flagged as unresolved. A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation.

getPort

getAddress

getHostName

Gets the hostname . Note: This method may trigger a name service reverse lookup if the address was created with a literal IP address.

getHostString

Returns the hostname, or the String form of the address if it doesn’t have a hostname (it was created using a literal). This has the benefit of not attempting a reverse lookup.

Читайте также:  Qpixmap python изменить размер

isUnresolved

toString

Constructs a string representation of this InetSocketAddress. This string is constructed by calling InetAddress.toString() on the InetAddress and concatenating the port number (with a colon). If the address is an IPv6 address, the IPv6 literal is enclosed in square brackets, for example: «localhost/[0:0:0:0:0:0:0:1]:80» . If the address is unresolved, is displayed in place of the address literal, for example «foo/:80» . To retrieve a string representation of the hostname or the address, use getHostString() , rather than parsing the string returned by this toString() method.

equals

Compares this object against the specified object. The result is true if and only if the argument is not null and it represents the same address as this object. Two instances of InetSocketAddress represent the same address if both the InetAddresses (or hostnames if it is unresolved) and port numbers are equal. If both addresses are unresolved, then the hostname and the port number are compared. Note: Hostnames are case insensitive. e.g. «FooBar» and «foobar» are considered equal.

hashCode

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Java net socket address

Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.

Uses of SocketAddress in java.net

This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname.

Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

Constructs a datagram packet for sending packets of length length with offset ioffset to the specified port number on the specified host.

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

Читайте также:  Python exception logger logging

Uses of SocketAddress in java.nio.channels

Methods in java.nio.channels that return SocketAddress
Modifier and Type Method and Description
abstract SocketAddress AsynchronousSocketChannel. getLocalAddress ()

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Источник

Uses of Class
java.net.SocketAddress

Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations.

Uses of SocketAddress in com.sun.nio.sctp

Returns the source socket address if the message has been received, otherwise the preferred destination of the message to be sent.

Returns all of the remote addresses to which the given association on this channel’s socket is connected.

Uses of SocketAddress in java.net

This class implements an IP Socket Address (IP address + port number) It can also be a pair (hostname + port number), in which case an attempt will be made to resolve the hostname.

Returns the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

Constructs a datagram packet for sending packets of length length with offset offset to the specified port number on the specified host.

Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.

Uses of SocketAddress in java.nio.channels

AsynchronousSocketChannel. connect (SocketAddress remote, A attachment, CompletionHandler handler)

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Оцените статью