I wish to creare in C language a single process which listen to 2 ports on the same IP address (TCP communication).
If It was possible I I have to create 2 socket with 2 bind or I can create 1 socket with 2 bind()
I would create 2 sockaddr_in structure with the same IP but different ports,


2 socket and 2 bind() example

Code:
int sa = socket(AF_INET, SOCK_STREAM, 0);
int sb = socket(AF_INET, SOCK_STREAM, 0);

struct sockaddr_in A;
A.sin_family = AF_INET;
A.sin_port = htons(6000);
inet_pton(AF_INET, "192.168.1.31", &A.sin_addr);

struct sockaddr_in B;
B.sin_family = AF_INET;
B.sin_port = htons(6000);
inet_pton(AF_INET, "192.168.1.31", &B.sin_addr);

bind(sa, (struct sockaddr*)&A, sizeof(A));
bind(sb, (struct sockaddr*)&B, sizeof(B));