|
|
我在程序中用sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);获得套接字
然后把网卡设置为混合模式,然后使用函数
recvfrom(sock, buffer, sizeof buffer, 0,(struct sockaddr *)&from, &fromlen);
这里面的from装的应是对方数据格式吧,他的sin_port=51868,buffer中装的应该是收到的数据包.
我再用
ip = (struct ip *)buffer;
tcp = (struct tcp *)(buffer + (4*ip->ip_length));
这时tcp的tcp_source_port=29325
我对recvfrom函数没理解好,想请教一下这两个端口为什么不一样?什么关系? |
|