WEB开发网      婵犵數濞€濞佳囧磹婵犳艾鐤炬い鎰堕檮閸嬬喐銇勯弽銊с€掗梻鍕閺岋箑螣娓氼垱笑闂佽姘﹂褔婀佸┑鐘诧工妤犲憡绂嶉崜褏纾奸弶鍫涘妼缁楁岸鏌熷畡鐗堝殗闁诡喒鏅犲畷褰掝敃閵堝棙顔忔繝鐢靛仦閸ㄥ爼骞愰幘顔肩;闁规崘绉ぐ鎺撳亹闁绘垶锕╁Λ鍕⒑閹肩偛濡奸悗娑掓櫇缁顓兼径妯绘櫇闂佹寧绻傞弻濠囨晝閸屾稓鍘甸柣搴㈢⊕閿氶柣蹇ョ稻缁绘繃绻濋崘銊т紝闂佽鍨伴崯鏉戠暦閻旂⒈鏁傞柛鈾€鏅欑槐妯衡攽閻愬樊鍤熷┑顔藉劤铻為柛鏇ㄥ墯閸欏繘鏌嶉崫鍕櫣缂佲偓婢跺绠鹃柟瀛樼箘閿涘秵顨ラ悙顏勭伈闁诡喖缍婂畷鎯邦槻婵℃彃顭烽弻娑㈠Ω閵夈儺鍔夌紓浣稿€哥粔褰掑极閹剧粯鏅搁柨鐕傛嫹 ---闂傚倷鐒︾€笛兠洪埡鍛闁跨噦鎷�
开发学院软件开发Java tcp connection setup的实现(一) 阅读

tcp connection setup的实现(一)

 2009-09-10 00:00:00 来源:WEB开发网 闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹闂傚倷绀侀幉锟犲垂閻㈠灚宕查柟鎵閸庡秵銇勯幒鎴濃偓鐢稿磻閹炬枼妲堟繛鍡楃С濞岊亞绱撻崒姘扁枌闁瑰嚖鎷�婵犵數濮幏鍐川椤撴繄鎹曢梻渚€娼уú銈吤洪妸鈺佺劦妞ゆ帊鑳堕埊鏇㈡煏閸モ晛浠х紒杈╁仱閺佹捇鏁撻敓锟�闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹  闂傚倷鑳舵灙缂佺粯顨呴埢宥夊即閵忕姵鐎梺缁樺姈椤愮厧鈽夊Ο閿嬬€婚梺褰掑亰閸撴稑鈻斿鑸碘拺闁告稑饪村▓鏃€绻涚仦鍌氬闁崇粯鎹囬獮瀣攽閹邦剚顔傛俊鐐€栧濠氬储瑜忛幉鎾晸閿燂拷
核心提示: 接下来看几个和bind相关的数据结构: 第一个是inet_hashinfo,它主要用来管理 tcp的bind hash bucket(在tcp的初始化函数中会将tcp_hashinfo初始化.然后在tcp_prot中会将tcp_hashinfo付给结构体h,然后相应的我们就可以通过sock中的s

接下来看几个和bind相关的数据结构:

第一个是inet_hashinfo,它主要用来管理 tcp的bind hash bucket(在tcp的初始化函数中会将tcp_hashinfo初始化.然后在tcp_prot中会将tcp_hashinfo付给结构体h,然后相应的我们就可以通过sock中的sock_common域来存取这个值).后面我们会分析这个流程.

Java代码  

struct inet_hashinfo { 
 /* This is for sockets with full identity only. Sockets here will 
 * always be without wildcards and will have the following invariant: 
 * 
 *     TCP_ESTABLISHED <= sk->sk_state < TCP_CLOSE 
 * 
 * TIME_WAIT sockets use a separate chain (twchain). 
 */ 
///下面会分析这个结构. 
 struct inet_ehash_bucket *ehash; 
 rwlock_t  *ehash_locks; 
 unsigned int  ehash_size; 
 unsigned int  ehash_locks_mask; 
 
 /* Ok, let's try this, I give up, we do need a local binding 
 * TCP hash as well as the others for fast bind/connect. 
 */ 
///表示所有的已经在使用的端口号的信息.这里bhash也就是一个hash链表,而链表的元素是inet_bind_bucket,紧接着我们会分析这个结构. 
 struct inet_bind_hashbucket *bhash; 
 
 unsigned int  bhash_size; 
 /* Note : 4 bytes padding on 64 bit arches */ 
 
 /* All sockets in TCP_LISTEN state will be in here. This is the only 
 * table where wildcard'd TCP sockets can exist. Hash function here 
 * is just local port number. 
 */ 
///listening_hash表示所有的处于listen状态的socket. 
 struct hlist_head listening_hash[INET_LHTABLE_SIZE]; 
 
 /* All the above members are written once at bootup and 
 * never written again _or_ are predominantly read-access. 
 * 
 * Now align to a new cache line as all the following members 
 * are often dirty. 
 */ 
 rwlock_t  lhash_lock ____cacheline_aligned; 
 atomic_t  lhash_users; 
 wait_queue_head_t lhash_wait; 
 struct kmem_cache  *bind_bucket_cachep; 
};

上一页  1 2 3 4 5 6 7  下一页

Tags:tcp connection setup

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接