Netty - UDP服务器(Netty - UDP server)
我有一个基于UDP Netty的服务器。 它有一个
SimpleChannelUpstreamHandler
流水线,我重写messageReceived
方法。我需要不时写回一些信息。 我只能通过使用
MessageEvent.getRemoteAddress()
的套接字信息和MessageEvent.getRemoteAddress()
的通道来完成此操作。 为了能够重复使用这些信息,我保存在一张静态地图中。这将变成
MessageEvent.getChannel().write("foo", MessageEvent.getRemoteAddress());
我所期望的是让
MessageEvent.getChannel().getRemoteAddress()
工作,事实并非如此。 它总是给我null
。
- 难道我做错了什么 ?
- 在保留某些成员的频道和远程地址的情况下,是否有更好的写回方式?
I am having an UDP Netty based server. It has a
SimpleChannelUpstreamHandler
pipelined where I override themessageReceived
method.I need to write back some information now and then. I could only do that by using the socket information from
MessageEvent.getRemoteAddress()
, and the channel fromMessageEvent.getChannel()
. In order to be able to reuse this information I keep in in a static map.This turns into
MessageEvent.getChannel().write("foo", MessageEvent.getRemoteAddress());
What I would have expected was to have
MessageEvent.getChannel().getRemoteAddress()
work, which is not the case. It always gives menull
.
- Am I doing something wrong ?
- Is there a better way for writing back than keeping the channel and remote address in some member ?
原文:https://stackoverflow.com/questions/17321850
满意答案
入口点RVA,入口点原始地址和图像基址以这种方式不相关。
图像库是“当它加载到存储器中时图像的第一个字节的首选地址”。 换句话说,假设没有冲突,它是加载时图像的虚拟地址。 如果在加载图像时存在地址冲突(例如,已经在重叠范围中加载了另一图像),则将为图像选择新的基地址。
RVA是相对虚拟地址。 它是“相对的”,因为它在实际加载图像时会发生变化。 它是未知基址的地址(例如,未加载图像时)。 加载映像后,RVA将成为虚拟地址(VA),即虚拟内存中的实际地址。
原始与RVA的区别在于对齐。 部分对齐(部分在加载到内存时对齐)以及文件对齐(部分中原始数据的对齐)。 这里的节对齐是0x1000,而文件对齐是0x200。
入口点RVA用于确定加载图像时入口点的VA(即入口点将位于虚拟地址
EntryPoint (rva) + ImageBase
)。 入口点原始地址是入口点所在文件的偏移量。本文档对齐有很好的解释。
The entry point RVA, entry point raw address, and image base address are not related in that way.
The image base is the "preferred address of the first byte of the image when it is loaded in memory". In other words, it's the virtual address of the image when it gets loaded assuming there's not a conflict. If there is an address conflict when the image is loaded (e.g. another image is already loaded in an overlapping range), then a new base address will be chosen for the image.
An RVA is a relative virtual address. It is "relative" in the sense that it is changed when the image is actually loaded. It's the address when the base address is not known (e.g. when the image isn't loaded). Once the image is loaded, the RVA becomes a virtual address (VA), an actual address in virtual memory.
The raw vs. RVA distinction is due to alignment. There is section alignment (the alignment of the sections when they get loaded into memory) as well as file alignment (the alignment of the raw data in the sections). The section alignment here is 0x1000 while the file alignment is 0x200.
The entry point RVA is used to determine the VA of the entry point when the image is loaded (i.e. the entry point will be located at virtual address
EntryPoint (rva) + ImageBase
). The entry point raw address is the offset into the file where the entry point is located.This document has a good explanation of alignment.
相关问答
更多汇编中每个NetModule的PE标头(PE Header for Each NetModule in Assembly)
如何读取内存中加载的模块的PE头?(How do I read the PE header of a module loaded in memory?)
PE:在.txt部分末尾添加代码(PE: Adding code at the end of .txt section)
如何理解此图中的PE头?(How to understand the PE header in this graph?)
PE标头的大小(The size of a PE Header)
如何读取过滤器驱动程序中当前进程的PE头(How read PE header of current process in filter driver)
为什么我的PE文件无效?(Why is my PE file invalid?)
PE .idata部分(PE .idata section)
是否为DLL模块评估了PE头和LARGEADDRESSAWARE?(PE header and LARGEADDRESSAWARE not evaluated for DLL modules?)
为什么存储在PE文件中的值是反向的?(Why value stored in PE file is reverse?)
相关文章
更多[Netty 1] 初识Netty
Netty源码分析
Netty入门实例-编写服务器端程序
Netty入门实例-时间服务器
基于C#的UDP协议的同步实现
Netty环境配置
Netty开发环境配置
LeetCode:Word Break(DP)
storm学习之Netty代替ZMQ
Netty基于流的传输处理
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!