使用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
最满意答案
是的,这肯定有好处。
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.
相关问答
更多-
gzipping之前缩小JavaScript有没有好处?(Is there a benefit to minifying JavaScript before gzipping it?)[2023-09-25]
是的,这肯定有好处。 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 ... -
Rails没有缩小(Rails not minifying)[2021-10-21]
这个答案适用于导轨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 ...
-
在构建过程中缩小之后更新JavaScript引用(Updating javascript references after minifying during build process)[2023-09-06]
我们使用自定义脚本管理器。 在我们的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.
-
从.ashx GZipping Javascript返回浏览器中的解码错误(GZipping Javascript from .ashx returns decoding error in browser)[2022-06-07]
这是一旦你解释了问题,你很快找到答案的事情之一。 我需要把回复写成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: ...