【问题标题】:Multiple Protocols for the same Interface同一接口的多个协议
【发布时间】:2012-07-23 22:38:36
【问题描述】:

是否可以将多个套接字链接到具有不同协议、UDP、TCP、RAW 等的一个接口(即以太网端口),因此如果通过以太网发送数据包,则只能由正确的套接字接收。

【问题讨论】:

    标签: sockets tcp udp ethernet


    【解决方案1】:

    我认为您在谈论套接字时使用的端口号之间的关系 和以太网端口。

    A Socket (TCP/UDP) Works in the Transport Layer.
    A port number comes here in the Layer and this is not the Ethernet port. 
    
    You can have a TCP Socket bound to  say port 88 as well as a UDP Socket bound to port 
    88.
    You may also have raw sockets, which can directly use the IP Headers.
    This may  require   root/administrative priviledge.
    
    Here seems you need to decode the IP packets and get to the specific protocol 
    on top it. 
    (There is a field in the IP header called Protocol which mentions which
    upper layer  protocol the packet belongs to)
    So there can be several sockets, which finally get the data from your ethernet port.
    

    一些基本概念请参考以下链接,

    http://en.wikipedia.org/wiki/Network_socket

    http://en.wikipedia.org/wiki/Raw_socket

    http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frzab6%2Fhowdosockets.htm

    【讨论】:

      猜你喜欢
      • 2021-10-14
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多