首页 \ 问答 \ 使用UDP处理POLL(POLL handling with UDP)

使用UDP处理POLL(POLL handling with UDP)

我一直在写(用万能的C)一个用UDP监听的服务器。 我有2个套接字监听同一个端口(IPv4和IPv6),我使用poll()来监控这两个套接字。

那么,在倾听时,处理民意调查的正确方法是什么? 有可能收到POLLHUP吗? 如果它可能如何处理? POLLERR也是如此

此外,它可以接收POLLRDBAND或POLLPRI? 如果是,那么它意味着什么以及必须如何处理?

提前致谢。

PS:所有问题都与UDP有关


I've been writing (with almighty C) a server wich listens in UDP. I've got 2 sockets listening on the same port (IPv4 and IPv6) and im using poll() to monitor both sockets.

So, when listening, what is the correct way to handle poll revents erros ? Is possible to receive a POLLHUP? If its possible how it must be handled? Same goes for POLLERR

Also, its possible to receive a POLLRDBAND or POLLPRI? If so then what does it means and how it must be handled?

Thanks in advance.

PS: All questions are UDP-related


原文:https://stackoverflow.com/questions/35468555
更新时间:2024-02-25 19:02

最满意答案

是的,这肯定有好处。

Minify是一种有损压缩,而gzipping是无损的。 Ergo,通过缩小您删除不需要的数据(如注释和长变量名),这将始终帮助您缩小文件。 即使使用gzip,在大多数情况下仍然会有所不同。

例:

function foo(this_is_my_variable){
    var this_is_my_other_variable = 0;
    this_is_my_other_variable = this_is_my_other_variable + this_is_my_variable;
    return this_is_my_other_variable;
}

这可能会缩小为:

function foo(a){
    var b = 0;
    b = b +a;
    return b;
}

或者如果缩小器很聪明:

function foo(a){
    return a;
}

所有代码都给出了相同的结果,但大小差别很大。


Yes, there is definately a benefit.

Minifying is a lossy compression whereas gzipping is lossless. Ergo, with minifying you remove unneeded data (like comments and long variablenames) which will always help to make your file smaller. Even with gzip there will still be a difference in most cases.

Example:

function foo(this_is_my_variable){
    var this_is_my_other_variable = 0;
    this_is_my_other_variable = this_is_my_other_variable + this_is_my_variable;
    return this_is_my_other_variable;
}

That might be minified to:

function foo(a){
    var b = 0;
    b = b +a;
    return b;
}

Or if the minifier is smart:

function foo(a){
    return a;
}

All code gives the same results, but the size differs a lot.

相关问答

更多
  • 是的,这肯定有好处。 Minify是一种有损压缩,而gzipping是无损的。 Ergo,通过缩小您删除不需要的数据(如注释和长变量名),这将始终帮助您缩小文件。 即使使用gzip,在大多数情况下仍然会有所不同。 例: function foo(this_is_my_variable){ var this_is_my_other_variable = 0; this_is_my_other_variable = this_is_my_other_variable + this_is_my_v ...
  • 这个答案适用于导轨4 当Rails-4不会缩小资产时,其中一个原因是RAILS_ENV未设置为生产。 这通常发生在您预编译资产并使用prod模式运行webrick时: rails s -e 'production' 但仍然产生的application.css和application.js被连接在一起,但没有被缩小。 要解决这个问题,请使用以下命令在预编译资源时指定env: $ RAILS_ENV =生产包exec rake资产:预编译 另外,如果您要从rails 3升级到rails 4,请注意product ...
  • 关于Google CDN上的GZip支持: Google的CDN支持GZip压缩。 据我所知它不支持Deflate,但这并不重要,因为所有主流浏览器都支持这两种。 您可以使用Rex Swain非常好的HTTP查看器自己验证; 只需在Accept-Encoding字段中输入“gzip”即可。 我玩了一些,我认为在发送压缩的Javascript之前,Google的CDN需要浏览器白名单。 如果您有时看到Google CDN的回复太多,那么这可能会让您感到沮丧。 如果你想玩这个,你可以再次使用Rex Swain的 ...
  • 你将有一个较小的文件加载到内存中进行解析,但在现代计算机上的收益微不足道。 通过简单的生产调试和更简单的构建过程,您可能会感觉更好。 You'll have a smaller file to load into memory for parsing, but the gains would be minuscule on a modern computer. You are likely better off with easy production debugging and a simpler bui ...
  • 我们使用自定义脚本管理器。 在我们的msbuild过程中,YUI Compressor用于创建缩小版本,但也可以将几个较小的.js文件合并为一个更大的文件。 这减少了请求的数量并因此加载时间。 缩小版本和组合版本与可调试版本并行创建。 在运行时期间,脚本管理器被控件调用以注册特定的脚本,这些脚本通过它们的非最小化名称来引用。 然后,脚本管理器将以DEBUG模式包含这些脚本(虽然我们执行的技巧包括HEAD中的脚本,而不是ClientScriptManager所做的)。 在RELEASE模式下,脚本管理器将替换 ...
  • 您可以通过shell中的chmod命令更改文件的权限 sudo chmod 777 filename 或者您也可以以root用户身份运行该过程。 You can either change the permission of the file by chmod command from shell sudo chmod 777 filename or you can alternatively run the process as a root user.
  • 这是一旦你解释了问题,你很快找到答案的事情之一。 我需要把回复写成Binary。 因此修改压缩算法以返回字节数组: public static byte[] CompressStringToArray(string text){ UTF8Encoding encoding = new UTF8Encoding(false); byte[] buffer = encoding.GetBytes(text); using(MemoryStream memoryStream = new ...
  • gzip压缩应该由服务器完成,因为服务器知道客户端是否能够解压缩数据。 如果配置正确,Web服务器将为您透明地处理它。 在lighttpd中,您可以像这样启用压缩: server.modules += ( "mod_compress" ) compress.cache-dir = "/var/cache/lighttpd/compress/" # change this as you want compress.filetype = ( "application/x-javascript", ...
  • 这是因为在使用quote_keys ,您将作为选项传递quote_keys ,而不是将它放在gulpfile的output选项中。 试试这个,你会得到所需的输出。 gulp.task('build1',function() { gulp.src(['a.js']).on('error', function(e){ console.log("error:",e) }).pipe(uglify({output:{quote_keys:true}})).on('error', f ...
  • 尝试在与httpCompression元素相同的级别上添加以下节点: http://www.iis.net/ConfigReference/system.webServer/urlCompression Try adding the following node on the same level as the httpCompression element: ...

相关文章

更多

最新问答

更多
  • 获取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))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。