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 getTrafficClass() method of Java Socket class returns the traffic class or type-of-service in the IP header sent from the specified Socket. Syntax public int getTrafficClass () Throws SocketException Parameter NA Return The getTrafficClass () method returns the traffic class or type-of-service. Throws SocketException - if there occurs an error while...
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 close() method of Java Socket class closes the specified socket. Once the socket has been closed, it is not available for further networking use. If the socket has a channel, the channel is also closed. Syntax public void close () throws IOException Parameter NA Return NA Specified by The close()...
2 min read
Java method The setOOBInline() method of Java Socket class enables or disables the SO_OOBInline. By default, the SO_OOBInline option is disabled. Syntax public void setOOBInline (Boolean on) throws SocketException Parameter The 'on' represents whether the SO_OOBInline option should enabled or not. Return NA Throws SocketException - if there is an error in the...
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 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 getOutputStream() method of Java Socket class returns an output stream for the given socket. If you close the returned OutputStream then it will close the linked socket. Syntax public OutputStream getOutputStream() throws IOException Parameter NA Return The getOutputStream() returns an output stream for writing bytes to this socket. Throws IOException-...
3 min read
Java The Socket class acts as an endpoint for communication between two machines. It implements client sockets. Methods Method Description bind(SocketAddress bindpoint) This method binds the given socket to the specified local address. close() This method closes the socket. connect(SocketAddress endpoint) connect(SocketAddress endpoint, int timeout) The connect() method connects this socket to the server. This method...
8 min read
Java Socket setSendBufferSize () method The setSendBufferSize () method of Java Socket class sets the SO_SNDBUF option to the given value for this socket. The size value should be greater than 0. Syntax public void setSendBufferSize (int size) throws SocketException Parameter The parameter 'size' represents the size to which the...
2 min read
Java method The setKeepAlive() method of Java Socket class returns a Boolean value 'true' if the write-half of the socket connection has been closed successfully else it returns false. Syntax public void setKeepAlive (boolean on) throws SocketException Parameter The parameter 'on' represents whether the socket should be enabled or...
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