当前在线人数18120
首页 - 分类讨论区 - 电脑网络 - 葵花宝典版 -阅读文章
未名交友
[更多]
[更多]
文章阅读:Re: a socket Question
[同主题阅读] [版面: 葵花宝典] [作者:keys] , 2004年11月04日17:08:17
keys
进入未名形象秀
我的博客
[上篇] [下篇] [同主题上篇] [同主题下篇]

发信人: keys (xiao dao), 信区: Programming
标  题: Re: a socket Question
发信站: Unknown Space - 未名空间 (Thu Nov  4 17:08:17 2004) WWW-POST

when you send a packet, OS's routing algorithm will check if destination ip
address is actually owned by its local interfaces. If yes, the packet will go
through loopback interface ('lo' 127.0.0.1) and never be sent out through the
physical interface, so you'd never see it appear on the wire through a sniffer
program like ethereal.

If you are using linux, there is kernel patch called send-to-self which can
bypass loopback interface. You need to apply this patch to your kernel source
and recompile a new kernel.

Another way is using a layer 2 socket (PF_PACKET on linux). This way you have
to assemble a packet from scratch, including ethernet header, ip header,
tcp/udp header etc. and implement TCP/IP stack by your self. Unless you are
just doing IP layer (layer 3) programming, it's not recommended.

If you are working on windows, I'm not sure if there are other ways doing
this.


【 在 oml (我是宝宝我怕谁@@) 的大作中提到: 】
: I have 2 NIC on my machine, each has a static ip address
: I want them talk to each other only through wire
: how can I do that?
: so far waht I did is bind different socket to them, but it won't work, even
if
: I don't have a loop, they can talk to each other
:
: what to do ne?
:
: Thanks
:


--
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 208.181.]

[上篇] [下篇] [同主题上篇] [同主题下篇]
[转寄] [转贴] [回信给作者] [修改文章] [删除文章] [同主题阅读] [从此处展开] [返回版面] [快速返回] [收藏] [举报]
 
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996