久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

C++ DGRAM 套接字獲取 RECEIVER 地址

C++ DGRAM socket get the RECEIVER address(C++ DGRAM 套接字獲取 RECEIVER 地址)
本文介紹了C++ DGRAM 套接字獲取 RECEIVER 地址的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

在 C++ 中,
如何獲取使用 recvfrom 收到的 UDP 數(shù)據(jù)包的接收方地址.我知道它應(yīng)該是我接收數(shù)據(jù)包的同一臺(tái)主機(jī),但我需要從接收到的數(shù)據(jù)包中提取它,以驗(yàn)證某些內(nèi)容.我該怎么做?

In C++,
how can I get the receiver address of the UDP packet which I have received using recvfrom. I know that it should be the same host on which I am receiving the packet, but I need to extract it from the received packet, in order to verify something. How can I do this?

我發(fā)現(xiàn)這樣做的一種方法是:

I found that one way of doing this is:

int r = getsockopt(receiver_sock, SOL_IP, SO_ORIGINAL_DST, (struct sockaddr *) &sender_addr, (socklen_t *)&addr_len);`

但我收到錯(cuò)誤:

error: ‘SO_ORIGINAL_DST’ was not declared in this scope

我正在使用適當(dāng)?shù)臉?biāo)題

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include </usr/src/linux-headers-2.6.32-21/include/linux/netfilter_ipv4.h>
#include <arpa/inet.h>    
#include <linux/netfilter.h>

使用 netfilter_ipv4 會(huì)導(dǎo)致其他錯(cuò)誤,例如未聲明 INT_MIN.但是,我認(rèn)為錯(cuò)誤是更根本的錯(cuò)誤,而不是包含正確的標(biāo)題.

Using netfilter_ipv4 gives other errors like INT_MIN not declared. However, I think the mistake is something more fundamental rather than inclusion of proper header.

請(qǐng)幫忙.

推薦答案

在 Linux 上你想使用 IP_PKTINFO 選項(xiàng),見(jiàn) ip(7)recvmsg(2) 調(diào)用.

On Linux you want to use IP_PKTINFO option, see ip(7), and the recvmsg(2) call.

Stevens 有這樣做的例子,但使用 IP_RECVDSTADDRIP_RECVIF 選項(xiàng)在 Linux 上不可用.

Stevens has examples of doing this but with IP_RECVDSTADDR and IP_RECVIF options that are not available on Linux.

這篇關(guān)于C++ DGRAM 套接字獲取 RECEIVER 地址的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Assertion failed (size.widthgt;0 amp;amp; size.heightgt;0)(斷言失敗(size.width0 amp;amp; size.height0))
Rotate an image in C++ without using OpenCV functions(在 C++ 中旋轉(zhuǎn)圖像而不使用 OpenCV 函數(shù))
OpenCV: process every frame(OpenCV:處理每一幀)
Why can#39;t I open avi video in openCV?(為什么我不能在 openCV 中打開(kāi) avi 視頻?)
OpenCV unable to set up SVM Parameters(OpenCV 無(wú)法設(shè)置 SVM 參數(shù))
Convert a single color with cvtColor(使用 cvtColor 轉(zhuǎn)換單一顏色)
主站蜘蛛池模板: 一区二区国产在线观看 | 亚洲www啪成人一区二区麻豆 | 色999日韩| 亚洲精品一区二三区不卡 | 青青草原综合久久大伊人精品 | 国产91在线 | 中日 | 国产亚洲精品久久久优势 | av中文字幕在线 | 欧美区日韩区 | 翔田千里一区二区 | 久久综合香蕉 | 青娱乐国产 | 亚洲精品福利在线 | 精品国产一级 | 亚洲成人精选 | 超碰伊人 | 99草免费视频 | 97久久精品午夜一区二区 | 日韩在线观看精品 | 成年人在线观看视频 | 99久久免费观看 | 久久精品亚洲精品国产欧美 | 国产99小视频 | 国产精品久久久久久 | 天天综合久久 | 久操伊人 | 国产精品一区久久久久 | 天天综合网天天综合色 | 亚洲福利一区 | 日日干日日操 | 亚洲天堂av在线 | 国产欧美日韩精品在线观看 | 成人黄色电影在线观看 | 日韩精品免费视频 | 男人av在线播放 | 亚洲 精品 综合 精品 自拍 | 99精品欧美一区二区蜜桃免费 | 国产一区二区日韩 | 国产精品免费观看 | 激情欧美一区二区三区中文字幕 | 欧美日一区 |