Для TCP-сервера со следующей структурой:
main(){
socket();
bind();
listen();
while(1){
accept();
fork();
if(child)
Process;
}
}
Он создает новый сокет для каждого клиента и взаимодействует со всеми клиентами, используя один и тот же порт. Таким образом, все сокеты привязываются к одному и тому же порту.
Я наткнулся на следующие комментарии при чтении код ядра (2.6.33.5):
48/* There are a few simple rules, which allow for local port reuse by
49 * an application. In essence:
50 *
51 * 1) Sockets bound to different interfaces may share a local port.
52 * Failing that, goto test 2.
53 * 2) If all sockets have sk->sk_reuse set, and none of them are in
54 * TCP_LISTEN state, the port may be shared.
55 * Failing that, goto test 3.
56 * 3) If all sockets are bound to a specific inet_sk(sk)->rcv_saddr local
57 * address, and none of them are the same, the port may be
58 * shared.
59 * Failing this, the port cannot be shared.
60 *
Итак, для приведенного выше TCP-сервера это третье правило, которому он соответствует?