in

how to read # gedit /proc/5812=pid/net/tcp file and need some expert explanation on this. Or maybe Simple explanation needed that make complete sense


so my program /proc/5812/net/tcp/ file looks like this

sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout inode                                                     
   0: 3500007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000   101        0 20861 1 ffff8ac807696040 100 0 0 10 5                     
   1: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 23685 1 ffff8ac80721abc0 100 0 0 10 0                     
   2: 0F0AA8C0:982C 84B5FA8E:01BB 06 00000000:00000000 03:0000083D 00000000     0        0 0 3 ffff8ac8068f11f0                                      
   3: 0F0AA8C0:8816 42B5FA8E:01BB 06 00000000:00000000 03:00001139 00000000     0        0 0 3 ffff8ac8068f1c98                                      
   4: 0F0AA8C0:BBA4 A213D9AC:01BB 06 00000000:00000000 03:00001521 00000000     0        0 0 3 ffff8ac8068f18b8                                      
   5: 0F0AA8C0:8CEC E2D03AD8:01BB 06 00000000:00000000 03:0000119D 00000000     0        0 0 3 ffff8ac8068f1aa8                                      
   6: 0F0AA8C0:8F16 45816597:01BB 01 00000000:00000000 00:00000000 00000000  1000        0 60827 1 ffff8ac756b6b480 51 4 30 10 -1                    

Can anyone please pin point how to translate just one line is above data

I like to know what is this

   0: 3500007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000   101        0 20861 1 ffff8ac807696040 100 0 0 10 5                     

In above?
What is remote address?
What is local address
what is st?
what is tx_queue?
what is rx_queue?
what is tr?
what is tm->when
what is retrnmt
And why uid is prited as 3 numbers, since I am running this process as sudo so I believe user is just one and NOT three uid’s should be printed
what is timeout?
it shows inode so can I get file descriptor from this and any of the above what is?

Can anyone please shed light on above,

And if My program is opening single socket connection and thats the only fd that in program that I coded then how to get that socket fd?

This is my simple client code that creates client socket to connect to 192.168.10.15 through TUN0 interface that assign tun0 to socket with help of ifreq and setsockopt..

I need any one please look at the above text and rows and please help me understand, How to interpret the above and accomplish what I am at

Thanks

End

This is my C client program creating single socket,

#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <errno.h>

#define MAX 80
#define PORT 80 
#define SA struct sockaddr
void func(int sockfd)
{
    char buff[MAX];
    int n;
    for (;;) {
        bzero(buff, sizeof(buff));
        printf("Enter the string : ");
        n = 0;
        while ((buff[n++] = getchar()) != 'n')
            ;
        write(sockfd, buff, sizeof(buff));
        bzero(buff, sizeof(buff));
        read(sockfd, buff, sizeof(buff));
        printf("From Server : %s", buff);
        if ((strncmp(buff, "exit", 4)) == 0) {
            printf("Client Exit...n");
            break;
        }
    }
}

int main()
{
    int sockfd, connfd;
    struct sockaddr_in servaddr, cli;

    sockfd = socket(AF_INET, SOCK_STREAM, 0);
struct ifreq ifr;
printf("%dn",sockfd);
    // Bind to a specific network interface (and optionally a specific local port)
    /*struct sockaddr_in localaddr;
    localaddr.sin_family = AF_INET;

    localaddr.sin_family = AF_INET;
        localaddr.sin_addr.s_addr = inet_addr("192.168.10.17");//htonl(INADDR_ANY);//inet_addr("192.168.10.17"); //you can give your server IP here
    localaddr.sin_port = htons(5001); //your port here
   
    
    bind(sockfd, (struct sockaddr *)&localaddr, sizeof(localaddr));
    */
    
    memset(&ifr, 0, sizeof(ifr));
    snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tun0");
    if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) < 0) {
        printf("errno  = %dn",errno);
        printf("error socoptn");
    }
    

    // Connect to the remote server
    struct sockaddr_in remoteaddr;
    remoteaddr.sin_family = AF_INET;
    remoteaddr.sin_addr.s_addr = inet_addr("192.168.10.15");
    remoteaddr.sin_port = htons(80);
    
    //printf("%dn",o);
    int o=connect(sockfd, (struct sockaddr *)&remoteaddr, sizeof(remoteaddr));
    printf("connect %dn",o);
    // socket create and varification
/*  sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd == -1) {
        printf("socket creation failed...n");
        exit(0);
    }
    else
        printf("Socket successfully created..n");

    bzero(&servaddr, sizeof(servaddr));*/

    // assign IP, PORT*/
/*  servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = inet_addr("192.168.10.15");
    servaddr.sin_port = htons(80);*/
    
    
    // connect the client socket to server socket

    // function for chat
    func(sockfd);

    // close the socket
    close(sockfd);
}



Source: https://stackoverflow.com/questions/70629935/how-to-read-gedit-proc-5812-pid-net-tcp-file-and-need-some-expert-explanation

Example Demonstrating React with Realtime API Backend

An implementation of webhook used to notify GitHub repository events to DingTalk