chore: remove trailing whitespace from README.md line 42

This commit is contained in:
2025-12-07 15:31:49 +00:00
parent 8c0c82335e
commit 36f84fba17
51 changed files with 2606 additions and 562 deletions
+17
View File
@@ -0,0 +1,17 @@
public class SocketBindDebug {
public static int main() {
Socket sock = new Socket();
System.out.print("Before bind, isBound: ");
System.out.println(sock.isBound());
sock.bind("0.0.0.0", 8888);
System.out.print("After bind, isBound: ");
boolean bound = sock.isBound();
System.out.println(bound);
sock.close();
return bound ? 1 : 0;
}
}
+21
View File
@@ -0,0 +1,21 @@
public class SocketBindExample {
public static int main() {
System.out.println("Socket Bind Example");
System.out.println("==================");
Socket sock = new Socket();
System.out.print("Socket bound before bind(): ");
System.out.println(sock.isBound());
sock.bind("127.0.0.1", 8888);
System.out.print("Socket bound after bind(): ");
System.out.println(sock.isBound());
sock.close();
System.out.println("Socket bind example completed successfully");
return 0;
}
}
+29
View File
@@ -0,0 +1,29 @@
public class SocketBufferSizeExample {
public static int main() {
System.out.println("Socket Buffer Size Example");
System.out.println("==========================");
Socket sock = new Socket();
System.out.print("Initial send buffer size: ");
System.out.println(sock.getSendBufferSize());
System.out.print("Initial receive buffer size: ");
System.out.println(sock.getReceiveBufferSize());
System.out.println("\nSetting buffer sizes to 32KB...");
sock.setSendBufferSize(32768);
sock.setReceiveBufferSize(32768);
System.out.print("New send buffer size: ");
System.out.println(sock.getSendBufferSize());
System.out.print("New receive buffer size: ");
System.out.println(sock.getReceiveBufferSize());
sock.close();
System.out.println("\nBuffer size configuration completed successfully");
return 0;
}
}
+55
View File
@@ -0,0 +1,55 @@
public class SocketLifecycleExample {
public static int main() {
System.out.println("Socket Lifecycle Example");
System.out.println("========================");
Socket client = new Socket();
System.out.println("\nInitial state:");
System.out.print(" Connected: ");
System.out.println(client.isConnected());
System.out.print(" Closed: ");
System.out.println(client.isClosed());
System.out.print(" Bound: ");
System.out.println(client.isBound());
System.out.println("\nBinding socket to local address...");
client.bind("127.0.0.1", 6666);
System.out.print(" Bound: ");
System.out.println(client.isBound());
System.out.println("\nCreating server and connecting...");
ServerSocket server = new ServerSocket(6667);
InetAddress addr = InetAddress.getLoopbackAddress();
client.connect(addr, 6667);
System.out.print(" Connected: ");
System.out.println(client.isConnected());
System.out.println("\nShutdown state:");
System.out.print(" Input shutdown: ");
System.out.println(client.isInputShutdown());
System.out.print(" Output shutdown: ");
System.out.println(client.isOutputShutdown());
System.out.println("\nPerforming half-close (shutdown output)...");
client.shutdownOutput();
System.out.print(" Output shutdown: ");
System.out.println(client.isOutputShutdown());
System.out.print(" Still connected: ");
System.out.println(client.isConnected());
System.out.println("\nClosing socket...");
client.close();
System.out.print(" Closed: ");
System.out.println(client.isClosed());
server.close();
System.out.println("\nSocket lifecycle example completed successfully");
return 0;
}
}
+43
View File
@@ -0,0 +1,43 @@
public class SocketOptionsExample {
public static int main() {
Socket socket = new Socket();
System.out.println("Socket Options Example");
System.out.println("=====================");
System.out.print("Initial KeepAlive: ");
System.out.println(socket.getKeepAlive());
socket.setKeepAlive(true);
System.out.print("After setKeepAlive(true): ");
System.out.println(socket.getKeepAlive());
socket.setKeepAlive(false);
System.out.print("After setKeepAlive(false): ");
System.out.println(socket.getKeepAlive());
System.out.print("Initial ReuseAddress: ");
System.out.println(socket.getReuseAddress());
socket.setReuseAddress(true);
System.out.print("After setReuseAddress(true): ");
System.out.println(socket.getReuseAddress());
socket.setReuseAddress(false);
System.out.print("After setReuseAddress(false): ");
System.out.println(socket.getReuseAddress());
socket.setSendBufferSize(32768);
System.out.print("Send buffer size: ");
System.out.println(socket.getSendBufferSize());
socket.setReceiveBufferSize(32768);
System.out.print("Receive buffer size: ");
System.out.println(socket.getReceiveBufferSize());
socket.close();
System.out.println("Socket closed");
return 0;
}
}
+36
View File
@@ -0,0 +1,36 @@
public class SocketShutdownExample {
public static int main() {
System.out.println("Socket Graceful Shutdown Example");
System.out.println("=================================");
ServerSocket server = new ServerSocket(7777);
Socket client = new Socket();
InetAddress addr = InetAddress.getLoopbackAddress();
client.connect(addr, 7777);
System.out.print("Input shutdown: ");
System.out.println(client.isInputShutdown());
System.out.print("Output shutdown: ");
System.out.println(client.isOutputShutdown());
System.out.println("\nShutting down input...");
client.shutdownInput();
System.out.print("Input shutdown after shutdownInput(): ");
System.out.println(client.isInputShutdown());
System.out.println("\nShutting down output...");
client.shutdownOutput();
System.out.print("Output shutdown after shutdownOutput(): ");
System.out.println(client.isOutputShutdown());
client.close();
server.close();
System.out.println("\nGraceful shutdown example completed successfully");
return 0;
}
}