Java Socket sendUrgentData() method25 Mar 2025 | 2 min read The sendUrgentData() method of Java Socket class sends one byte of urgent data on the socket. The byte should be the lowest eight bits of the data parameter. SyntaxParameterThe "data" parameter represents the byte of data to send. ReturnNA ThrowsIOException - if there is an error while sending the data. Example 1Output: The socket is connected: true Data has been sent successfully... Example 2Output: Exception in thread "main" java.io.IOException: Socket Closed The socket is connected: true at java.net.AbstractPlainSocketImpl.sendUrgentData(AbstractPlainSocketImpl.java:591) at java.net.PlainSocketImpl.sendUrgentData(PlainSocketImpl.java:262) at java.net.Socket.sendUrgentData(Socket.java:1067) at com.tpointtech.JavaSocketSendUrgentDataExample2.main(JavaSocketSendUrgentDataExample2.java:23) Example 3Output: The socket is connected: false Socket is not connected... Please connect the socket with a valid socket address and port number Next TopicJava Socket Class |
Java method The get00BInline() method of Java Socket class tests whether the S0_00BINLINE option is enabled or not. Syntax public boolean get00BInline () Parameter NA Return The get00BInline() method returns a Boolean value 'true if the S0_00BINLINE is enabled else it returns false. Throws SocketException - if an error is there in...
2 min read
Java method The getChannel() method of Java Socket class returns the unique SocketChannel object linked with this socket. Syntax public SocketChannel getChannel() Parameter NA Return The getChannel() method either returns the socket channel linked with this socket or returns null if the socket was not created for the specified channel. Example...
2 min read
Java method The getLocalPort() method of Java Socket class returns the local port number to which the specified socket is bound. If the socket was being closed, this method will return the connected port number after the socket is closed. Syntax public int getLocalPort() Parameter NA Return The getLocalPort () method...
2 min read
Java method The getRemoteSocketAddress () method of Java Socket class returns the address of the endpoint of the specified socket if it is connected else it will return null if this socket is not connected. Syntax public SocketAddress getRemoteSocketAddress () Parameter NA Return The getRemoteSocketAddress () method either returns the SocketAddress...
3 min read
Java method The setSoTimeout () method of Java Socket class enables or disables the SO_TIMEOUT option with the given timeout value, in milliseconds. The timeout value should be greater than 0 otherwise, it will throw an error. Syntax public void setSoTimeout (int timeout) throws SocketException Parameter The...
3 min read
Java method The getInetAddress() method of Java Socket class returns the address to which the socket is connected. If the socket is being closed, this method will return the connected address after the socket is closed. Syntax public InetAddress getInetAddress () Parameter NA Return The getInetAddress () method either returns the...
3 min read
Java method The getSendBufferSize () method of Java Socket class returns the buffer size(SO_SNDBUF) used by the platform for output on this socket. Syntax public int getSendBufferSize () Parameter NA Return The getSendBufferSize () method returns the value of the SO_SNDBUF option of the specified Socket. Throws SocketException - if an error...
2 min read
Java method The getPort() method of Java Socket class returns the remote port number to which the socket is connected. This method will return the port number even after the socket is closed. Syntax public int getPort () Parameter NA Return The getPort() method either returns the port number to which...
2 min read
Java method The bind() method of Java Socket class binds the socket to a local address. If the specified address is null, then the system will automatically pick up a port number and a valid local address to bind with the socket. Syntax public void bind(SocketAddress bindpoint)...
3 min read
Java method The getTcpNoDelay () method of Java Socket class returns the setting for SO_TIMEOUT option if it is enabled, else it returns false. Syntax public boolean getTcpNoDelay () Parameter NA Return The getTcpNoDelay () method returns a Boolean value 'true' if the TCP_NODELAY is enabled. Throws SocketException - if an error is...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India