Saturday, June 29, 2024

How to Create a TCP Client and Server in Java? Example Tutorial

Hello guys, if you want to create client server application in Java then you need to learn Java networking API an classes like Socket and ServerSocket. In the past, I have showed you how to create an HTTP Client and Server in Java where I talked about these classes. In this Java networking tutorial, we will learn how to create a simple TCP server and Client in Java using networking classes provided by JDK in java.net package. Earlier, I have showed you how to create HTTP Server, which is actually a TCP/IP Server but here we'll do it again, along with writing a TCP client as well. Though you can test your TCP server using telnet, I'll show you how to connect to it using a TCP client written in Java. 

Monday, April 8, 2024

How to fix java.net.SocketException: Software caused connection abort: recv failed

Out of many client servers related socket errors here is one more interesting socket related error from the Java program, "java.net.SocketException: Software caused connection abort: recv failed". The key point in this error message is "abort" and "recv", which means is someone (client or server) is trying to read from a closed connection. This error usually comes at the client socket end, when the server closed the connection before the client has read the response, but, in general, it can come to an end of the TCP socket, so you must check the log files for both clients and server to find out who is complaining. If the Server is complaining then it's fine and the client has closed the TCP connection may be due to timeout or any RuntimeException at the client end.

Thursday, September 28, 2023

Fixing java.net.BindException: Cannot assign requested address: JVM_Bind in Tomcat, Jetty

One of the most dreaded errors in Java-based client server-based applications is a networking-related error, e.g. java.net.BindException: Cannot assign requested address: JVM_Bind. I have faced this issue while working with web servers like Tomcat, Jetty, and Weblogic before, but yesterday it came again when one of my colleagues faced this issue in Windows. As soon as Java programmers see java.net.BindException, they come to the conclusion that it's an issue with two processes listening on the same port and often mistook it for Java.net.BindException: Address already in use: JVM_Bind:8080, which is slightly different than this.