Skip to content

[TCPView} many sockets in TIME Wait state: TCPView stopps displaying informations #879

@JochenBaier

Description

@JochenBaier

If I have TCP/IP client server application which connects/disconnect in a loop many sockets will go into TIME WAIT state.
TCPView will stop showing information in this case:

Image

netstat -a -p TCP does show the states:

Image

Because TCPView does not display the states I had problems to find a bug related to TIME WAIT in my software.
After I used netstat I was able to fix the problem.

Version: 4.19 64 bit, Windows 11 (and Windows 10)

python client/server code to reproduce:

server.py:

import socket

def start_server():
    host = '127.0.0.1'  # Localhost
    port = 65432        # Port to bind the server

    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.bind((host, port))
    server_socket.listen()

    print(f"Server listening on {host}:{port}...")

    while True:
        conn, addr = server_socket.accept()
        print(f"Connected by {addr}")
        conn.sendall(b"Hello, Client!")
        conn.close()

if __name__ == "__main__":
    start_server()

client.py:

import socket
import time

def connect_to_server():
    host = '127.0.0.1'  # Server's IP
    port = 65432         # Same port as the server

    while True:
        try:
            # Create a socket object and connect to the server
            client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            client_socket.connect((host, port))

            # Receive data from server
            data = client_socket.recv(1024)
            print(f"Received from server: {data.decode()}")

            # Close the connection after receiving data
            client_socket.close()

        except ConnectionRefusedError:
            print("Server is not available. Retrying in 3 seconds...")
            time.sleep(3)  # Wait before retrying

if __name__ == "__main__":
    connect_to_server()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions