def METHOD_NAME(data, ip):
    create_client()
    direction = "accept" if data.direction==0 else "connect"
    if ip==4:
        daddr = inet_ntop(AF_INET, pack("I", data.daddr)).encode()
        saddr = inet_ntop(AF_INET, pack("I", data.saddr)).encode()
    else:
        daddr = inet_ntop(AF_INET6, data.daddr).encode()
        saddr = inet_ntop(AF_INET6, data.saddr).encode()
    json_body = [
        {
            "measurement": "tcp_connection",
            "fields": {
                "PID": data.pid,
                "TASK": data.task,
                "IP": data.ip,
                "DADDR": daddr,
                "DPORT": data.dport,
                "SADDR": saddr,
                "SPORT": data.sport,
                "DIRECTION": direction
            }
        }
    ]
    client.write_points(json_body)