{"id":1651,"date":"2026-10-28T12:00:00","date_gmt":"2026-10-28T03:00:00","guid":{"rendered":"https:\/\/quantumsea.net\/?p=1651"},"modified":"2026-10-25T12:19:43","modified_gmt":"2026-10-25T03:19:43","slug":"qs-msg-peek-receive-queue-20261025","status":"publish","type":"post","link":"https:\/\/quantumsea.net\/?p=1651","title":{"rendered":"MSG_PEEK\u3001\u53d7\u4fe1\u30c7\u30fc\u30bf\u3092\u6d88\u8cbb\u305b\u305a\u306b\u5148\u982d\u3092\u8aad\u3080\u4ed5\u7d44\u307f"},"content":{"rendered":"<p>\u901a\u4fe1\u306e\u5148\u982d\u306b\u3042\u308b\u6570\u30d0\u30a4\u30c8\u3092\u898b\u3066\u3001\u3069\u306e\u51e6\u7406\u3078\u6e21\u3059\u304b\u6c7a\u3081\u305f\u3044\u3002\u305f\u3060\u3001\u305d\u306e\u6570\u30d0\u30a4\u30c8\u306f\u5f8c\u3067\u52d5\u304f\u51e6\u7406\u306b\u3082\u8aad\u3093\u3067\u307b\u3057\u3044\u3002\u53d7\u4fe1\u3092\u4e00\u5ea6\u9032\u3081\u3066\u3057\u307e\u3046\u3068\u3001\u8aad\u307f\u53d6\u3063\u305f\u90e8\u5206\u3092\u81ea\u5206\u3067\u4fdd\u5b58\u3057\u3066\u5f15\u304d\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30bd\u30b1\u30c3\u30c8\u306e\u53d7\u4fe1\u306b\u6307\u5b9a\u3059\u308b<strong>MSG_PEEK<\/strong>\u306f\u3001\u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u5f85\u3061\u306e\u5217\u3078\u6b8b\u3057\u305f\u307e\u307e\u3001\u5185\u5bb9\u3092\u8aad\u3080\u305f\u3081\u306e\u30d5\u30e9\u30b0\u3067\u3059\u3002<\/p>\n<section class=\"influvetor-quick-summary\" aria-label=\"\u7c21\u5358\u306b\u307e\u3068\u3081\u308b\u3068\uff1f\">\n<p><strong>\u7c21\u5358\u306b\u307e\u3068\u3081\u308b\u3068\uff1f<\/strong><\/p>\n<ul>\n<li>\u901a\u5e38\u306eMSG_PEEK\u306f\u3001\u53d7\u4fe1\u5f85\u3061\u306e\u5148\u982d\u3092\u6d88\u8cbb\u305b\u305a\u306b\u8aad\u307f\u307e\u3059\u3002\u7e70\u308a\u8fd4\u3057\u3066\u3082\u3001\u81ea\u52d5\u7684\u306b\u6b21\u306e\u90e8\u5206\u3078\u9032\u3080\u308f\u3051\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/li>\n<li>\u5148\u306b\u8997\u3044\u3066\u3082\u3001\u305d\u306e\u30c7\u30fc\u30bf\u3092\u81ea\u5206\u7528\u306b\u78ba\u4fdd\u3057\u305f\u3053\u3068\u306b\u306f\u306a\u308a\u307e\u305b\u3093\u3002\u5225\u306e\u51e6\u7406\u304c\u53d7\u4fe1\u3059\u308b\u3068\u3001\u5f8c\u306e\u8aad\u307f\u53d6\u308a\u4f4d\u7f6e\u306f\u5909\u308f\u308a\u307e\u3059\u3002<\/li>\n<li>\u8aad\u3081\u308b\u72b6\u614b\u3001\u4eca\u306f\u30c7\u30fc\u30bf\u304c\u306a\u3044\u72b6\u614b\u3001\u9001\u4fe1\u7d42\u4e86\u5f8c\u306eEOF\u3092\u533a\u5225\u3057\u307e\u3059\u3002\u8997\u304f\u3060\u3051\u306e\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059\u3068\u3001\u53d7\u4fe1\u5f85\u3061\u306e\u30c7\u30fc\u30bf\u304c\u6b8b\u308a\u7d9a\u3051\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/section>\n<h2>\u300c\u5185\u5bb9\u304c\u8fd4\u308b\u300d\u3068\u300c\u5217\u304b\u3089\u53d6\u308a\u51fa\u3059\u300d\u3092\u5206\u3051\u308b<\/h2>\n<p>\u30bd\u30b1\u30c3\u30c8\u306f\u3001\u901a\u4fe1\u306e\u76f8\u624b\u3068\u30c7\u30fc\u30bf\u3092\u3084\u308a\u53d6\u308a\u3059\u308b\u305f\u3081\u306e\u7a93\u53e3\u3067\u3059\u3002\u5c4a\u3044\u305f\u30c7\u30fc\u30bf\u306e\u3046\u3061\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u307e\u3060\u53d7\u3051\u53d6\u3063\u3066\u3044\u306a\u3044\u90e8\u5206\u306f\u3001OS\u5074\u3067\u8aad\u307f\u53d6\u308a\u3092\u5f85\u3063\u3066\u3044\u307e\u3059\u3002\u901a\u5e38\u306erecv\u306f\u305d\u3053\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308a\u3001\u8aad\u307f\u7d42\u3048\u305f\u5206\u3060\u3051\u5148\u3078\u9032\u307f\u307e\u3059\u3002\u4e00\u65b9\u3001MSG_PEEK\u3092\u4ed8\u3051\u305frecv\u3067\u306f\u3001\u5185\u5bb9\u304c\u8fd4\u3063\u3066\u3082\u305d\u306e\u90e8\u5206\u304c\u53d7\u4fe1\u5f85\u3061\u306e\u5217\u306b\u6b8b\u308a\u307e\u3059\u3002[1]<\/p>\n<p>Python\u306a\u3089<code>sock.recv(2, socket.MSG_PEEK)<\/code>\u3068\u3044\u3046\u5f62\u3067\u3059\u30022\u306f\u6b32\u3057\u3044\u30c7\u30fc\u30bf\u306e\u4e0a\u9650\u3067\u3001\u7d50\u679c\u306fbytes\u3068\u3057\u3066\u8fd4\u308a\u307e\u3059\u3002\u30d5\u30e9\u30b0\u306e\u6709\u7121\u3067\u5909\u308f\u308b\u306e\u306f\u53d7\u4fe1\u5f85\u3061\u306e\u30c7\u30fc\u30bf\u306e\u6271\u3044\u3067\u3059\u3002\u300c\u898b\u308b\u3060\u3051\u300d\u3068\u3044\u3046\u540d\u524d\u3067\u3082\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3078\u5185\u5bb9\u3092\u6e21\u3055\u305a\u306b\u6e08\u3080\u6a5f\u80fd\u3084\u3001\u30b3\u30d4\u30fc\u306e\u8cbb\u7528\u304c\u306a\u304f\u306a\u308b\u6307\u5b9a\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002[2]<\/p>\n<p>\u3053\u3053\u304b\u3089\u306f\u3001\u30c7\u30fc\u30bf\u3092\u9023\u7d9a\u3057\u305f\u30d0\u30a4\u30c8\u5217\u3068\u3057\u3066\u6271\u3046\u30b9\u30c8\u30ea\u30fc\u30e0\u30bd\u30b1\u30c3\u30c8\u3067\u8003\u3048\u307e\u3059\u3002\u5148\u982d\u4f4d\u7f6e\u3092\u5909\u66f4\u3059\u308b\u7279\u5225\u306a\u30bd\u30b1\u30c3\u30c8\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u4f7f\u308f\u305a\u3001\u53d7\u4fe1\u30b5\u30a4\u30ba\u306f1\u4ee5\u4e0a\u306b\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30b0\u30e9\u30e0\u306e\u533a\u5207\u308a\u3084\u9577\u3055\u30bc\u30ed\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u3001\u4eca\u56de\u306e\u4f8b\u306b\u542b\u3081\u307e\u305b\u3093\u3002<\/p>\n<h2>AB\u3092\u898b\u305f\u5f8c\u3082\u3001\u6b21\u306fAB\u304b\u3089\u8aad\u3081\u308b<\/h2>\n<p>\u53d7\u4fe1\u5f85\u3061\u306e\u5217\u306b<code>ABCDEF<\/code>\u304c\u5c4a\u3044\u305f\u3068\u3057\u307e\u3059\u3002\u6700\u521d\u306b2\u30d0\u30a4\u30c8\u3092\u8997\u304f\u3068AB\u3001\u7d9a\u3044\u30664\u30d0\u30a4\u30c8\u3092\u8997\u304f\u3068ABCD\u304c\u8fd4\u308a\u307e\u3059\u3002\u6700\u521d\u306e\u64cd\u4f5c\u3067AB\u3092\u6d88\u8cbb\u3057\u3066\u3044\u306a\u3044\u305f\u3081\u30012\u56de\u76ee\u3082\u540c\u3058\u5148\u982d\u304b\u3089\u59cb\u307e\u308b\u306e\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u901a\u5e38\u306erecv\u30672\u30d0\u30a4\u30c8\u3092\u53d7\u3051\u53d6\u308b\u3068AB\u304c\u8fd4\u308a\u3001\u521d\u3081\u3066\u53d7\u4fe1\u5f85\u3061\u306e\u5148\u982d\u304cC\u3078\u79fb\u308a\u307e\u3059\u3002\u305d\u306e\u5f8c\u306b4\u30d0\u30a4\u30c8\u3092\u8997\u3051\u3070CDEF\u3067\u3059\u3002\u8997\u304d\u8aad\u307f\u3092\u4f55\u56de\u5b9f\u884c\u3057\u305f\u304b\u3067\u306f\u306a\u304f\u3001\u3069\u306e\u64cd\u4f5c\u304c\u5b9f\u969b\u306b\u30c7\u30fc\u30bf\u3092\u6d88\u8cbb\u3057\u305f\u304b\u3092\u8ffd\u3046\u3068\u3001\u4f4d\u7f6e\u3092\u898b\u5931\u3044\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<figure style=\"margin:24px auto;width:100%;max-width:720px;\"><img decoding=\"async\" src=\"https:\/\/quantumsea.net\/wp-content\/uploads\/2026\/10\/qs-msg-peek-receive-queue-20261025-figure-102e1a16ba16.png\" alt=\"ABCDEF\u3092\u53d7\u4fe1\u5f85\u3061\u306b\u3057\u305f\u5b9f\u9a13\u306e\u9806\u5e8f\u3002peek 2\u3067AB\u3001peek 4\u3067ABCD\u304c\u8fd4\u3063\u3066\u3082\u5217\u306fABCDEF\u306e\u307e\u307e\u3002\u901a\u5e38\u306erecv 2\u3067AB\u3092\u53d7\u3051\u53d6\u308b\u3068\u5217\u304cCDEF\u306b\u306a\u308a\u3001\u6b21\u306epeek 4\u306fCDEF\u3092\u8fd4\u3057\u305f\u3002\" style=\"display:block;width:100%;max-width:100%;height:auto;\"\/><figcaption>\u540c\u3058\u53d7\u4fe1\u5074\u3067\u9806\u756a\u306b\u64cd\u4f5c\u3057\u305f\u7d50\u679c\u3092\u56f3\u793a\u3002peek\u306fMSG_PEEK\u4ed8\u304drecv\u306e\u7565\u8a18\u3002\u6587\u5b57\u306f\u54041\u30d0\u30a4\u30c8\u3067\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u4e0a\u306e\u30d1\u30b1\u30c3\u30c8\u3092\u8868\u3059\u56f3\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/figcaption><\/figure>\n<p>\u3053\u306e\u9806\u5e8f\u306f\u3001macOS 26.6.2\u30fbPython 3.12.14\u306e<code>socketpair<\/code>\u3067\u4f5c\u3063\u305f\u30ed\u30fc\u30ab\u30eb\u306eAF_UNIX \/ SOCK_STREAM\u30bd\u30b1\u30c3\u30c8\u30673\u56de\u5b9f\u884c\u3057\u3001\u3044\u305a\u308c\u3082\u540c\u3058\u7d50\u679c\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u901a\u5e38\u306erecv\u3067\u6b8b\u308a\u306eCDEF\u3092\u53d7\u3051\u53d6\u308b\u307e\u3067\u3001\u5217\u306b\u306f\u672a\u8aad\u306e\u30c7\u30fc\u30bf\u304c\u6b8b\u308a\u307e\u3057\u305f\u3002Linux\u306e\u4ed5\u69d8\u8aac\u660e\u3068\u3001\u3053\u306eMac\u3067\u306e\u89b3\u6e2c\u306f\u5206\u3051\u3066\u3044\u307e\u3059\u3002TCP\u306e\u30d1\u30b1\u30c3\u30c8\u5206\u5272\u3084\u901a\u4fe1\u901f\u5ea6\u3092\u6e2c\u3063\u305f\u5b9f\u9a13\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>\u8997\u3044\u305f\u5185\u5bb9\u304c\u3001\u5f8c\u3067\u3082\u81ea\u5206\u306b\u5c4a\u304f\u3068\u306f\u9650\u3089\u306a\u3044<\/h2>\n<p>\u5148\u982d\u3092\u898b\u305f\u76f4\u5f8c\u306b\u5225\u306e\u51e6\u7406\u304c\u540c\u3058\u53d7\u4fe1\u5074\u304b\u3089\u8aad\u3080\u3068\u3001\u72b6\u6cc1\u306f\u5909\u308f\u308a\u307e\u3059\u3002\u4eca\u56de\u306e\u5225\u306e\u8a66\u884c\u3067\u306f\u3001ABCD\u3092\u9001\u308a\u3001\u6700\u521d\u306e\u8aad\u307f\u624b\u304cAB\u3092\u8997\u3044\u305f\u5f8c\u3001\u8907\u88fd\u3057\u305f\u30bd\u30b1\u30c3\u30c8\u3092\u6301\u3064\u8aad\u307f\u624b\u306b\u901a\u5e38\u306erecv\u3067AB\u3092\u53d7\u3051\u53d6\u3089\u305b\u307e\u3057\u305f\u3002\u6700\u521d\u306e\u8aad\u307f\u624b\u304c\u6539\u3081\u3066recv\u3059\u308b\u3068\u3001\u8fd4\u3063\u305f\u306e\u306fCD\u3067\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u8a66\u884c\u306f\u3001\u64cd\u4f5c\u306e\u9806\u5e8f\u3092\u610f\u56f3\u7684\u306b\u56fa\u5b9a\u3057\u305f\u3082\u306e\u3067\u3059\u3002\u540c\u6642\u5b9f\u884c\u306e\u7af6\u5408\u304c\u3069\u306e\u983b\u5ea6\u3067\u8d77\u304d\u308b\u304b\u306f\u6e2c\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u305f\u3060\u3001\u8997\u304d\u8aad\u307f\u304c\u30c7\u30fc\u30bf\u306e\u4e88\u7d04\u3084\u5360\u6709\u306b\u306a\u3089\u306a\u3044\u3053\u3068\u306f\u3001\u3053\u306e\u9806\u5e8f\u3067\u3082\u78ba\u304b\u3081\u3089\u308c\u307e\u3059\u3002\u8907\u6570\u306e\u8aad\u307f\u624b\u3092\u7f6e\u304f\u8a2d\u8a08\u3067\u306f\u3001\u300c\u5148\u307b\u3069\u898b\u305f\u5148\u982d\u3092\u3001\u3053\u306e\u5f8c\u306e\u51e6\u7406\u304c\u5fc5\u305a\u53d7\u3051\u53d6\u308b\u300d\u3068\u3044\u3046\u524d\u63d0\u3092\u7f6e\u3051\u307e\u305b\u3093\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001\u5148\u982d\u306e\u8b58\u5225\u5b50\u3092\u898b\u3066\u51e6\u7406\u3092\u9078\u3076\u90e8\u5206\u3068\u3001\u672c\u4f53\u3092\u8aad\u307f\u53d6\u308b\u90e8\u5206\u3092\u5206\u3051\u308b\u306a\u3089\u3001\u8ab0\u304c\u53d7\u4fe1\u3092\u9032\u3081\u308b\u304b\u3092\u4e00\u3064\u306e\u6d41\u308c\u3068\u3057\u3066\u7ba1\u7406\u3057\u307e\u3059\u3002\u8aad\u307f\u624b\u304c\u4e00\u3064\u306a\u3089MSG_PEEK\u3067\u5148\u982d\u3092\u6b8b\u3059\u65b9\u6cd5\u304c\u4f7f\u3048\u307e\u3059\u3002\u8907\u6570\u306e\u6bb5\u968e\u3067\u53d7\u4fe1\u5185\u5bb9\u3092\u5171\u6709\u3057\u305f\u3044\u306a\u3089\u3001\u4e00\u3064\u306e\u8aad\u307f\u624b\u304c\u53d7\u4fe1\u3057\u3066\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u306e\u30d0\u30c3\u30d5\u30a1\u3078\u4fdd\u5b58\u3057\u3001\u5fc5\u8981\u306a\u90e8\u5206\u3092\u5404\u51e6\u7406\u3078\u6e21\u3059\u69cb\u6210\u3082\u6bd4\u8f03\u5bfe\u8c61\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u8aad\u3081\u308b\u3068\u3044\u3046\u901a\u77e5\u306f\u3001\u8997\u3044\u3066\u3082\u6d88\u3048\u306a\u3044<\/h2>\n<p>\u53d7\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u307e\u3067\u5f85\u3064\u4ed5\u7d44\u307f\u3068\u3057\u3066\u3001select\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002Linux\u306eselect\u306e\u8aac\u660e\u3067\u3044\u3046\u300c\u8aad\u307f\u53d6\u308a\u53ef\u80fd\u300d\u306f\u3001\u305d\u306e\u8aad\u307f\u53d6\u308a\u304c\u5f85\u305f\u305a\u306b\u9032\u3081\u3089\u308c\u308b\u72b6\u614b\u3067\u3059\u3002\u5c4a\u3044\u305f\u30c7\u30fc\u30bf\u304c\u3042\u308b\u5834\u5408\u3060\u3051\u3067\u306a\u304f\u3001EOF\u3092\u8fd4\u305b\u308b\u5834\u5408\u3082\u542b\u307e\u308c\u307e\u3059\u3002[3]<\/p>\n<p>\u4eca\u56de\u306eMac\u3067\u5f85\u3061\u6642\u9593\u30920\u306b\u3057\u305fselect\u3092\u547c\u3076\u3068\u3001AB\u3092\u8997\u3044\u305f\u5f8c\u3082\u8aad\u307f\u53d6\u308a\u53ef\u80fd\u3067\u3057\u305f\u3002\u901a\u5e38\u306erecv\u3067AB\u3092\u6d88\u8cbb\u3057\u3066\u3082CDEF\u304c\u6b8b\u308b\u9593\u306f\u540c\u3058\u3067\u3059\u3002\u6b8b\u308a\u3092\u3059\u3079\u3066\u53d7\u3051\u53d6\u308a\u3001\u76f8\u624b\u304c\u307e\u3060\u958b\u3044\u3066\u3044\u308b\u72b6\u614b\u306b\u306a\u3063\u3066\u521d\u3081\u3066\u3001\u8aad\u307f\u53d6\u308a\u53ef\u80fd\u3067\u306f\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u9055\u3044\u306f\u3001\u53d7\u4fe1\u901a\u77e5\u3092\u53d7\u3051\u305f\u51e6\u7406\u304c\u8997\u304f\u3060\u3051\u3067\u623b\u308b\u3068\u304d\u306b\u52b9\u3044\u3066\u304d\u307e\u3059\u3002\u672a\u8aad\u30c7\u30fc\u30bf\u3092\u6b8b\u3057\u305f\u307e\u307e\u3001\u8aad\u3081\u308b\u304b\u3069\u3046\u304b\u3092\u4f55\u5ea6\u3082\u8abf\u3079\u308c\u3070\u3001\u540c\u3058\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u5148\u982d\u306e\u5224\u5b9a\u5f8c\u306f\u8ab0\u304c\u6d88\u8cbb\u3059\u308b\u306e\u304b\u3001\u307e\u3060\u5fc5\u8981\u306a\u9577\u3055\u304c\u306a\u3044\u306a\u3089\u3069\u3046\u5f85\u3064\u306e\u304b\u307e\u3067\u6c7a\u3081\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u7279\u5b9a\u306e\u30a4\u30d9\u30f3\u30c8\u901a\u77e5\u65b9\u5f0f\u3059\u3079\u3066\u304c\u540c\u3058\u52d5\u4f5c\u3092\u3059\u308b\u3001\u3068\u3044\u3046\u6bd4\u8f03\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h2>\u77ed\u3044\u7d50\u679c\u3068EOF\u3092\u3001\u5fc5\u8981\u306a\u9577\u3055\u3068\u4e00\u7dd2\u306b\u8aad\u3080<\/h2>\n<p>MSG_PEEK\u306f\u3001\u6307\u5b9a\u3057\u305f\u30d0\u30a4\u30c8\u6570\u304c\u5fc5\u305a\u305d\u308d\u3046\u307e\u3067\u5f85\u3064\u3068\u3044\u3046\u6307\u793a\u3067\u3082\u3042\u308a\u307e\u305b\u3093\u3002Linux\u306e\u901a\u5e38\u306e\u53d7\u4fe1\u306f\u3001\u8981\u6c42\u3057\u305f\u4e0a\u9650\u307e\u3067\u306e\u7bc4\u56f2\u3067\u3001\u305d\u306e\u6642\u70b9\u3067\u8fd4\u305b\u308b\u30c7\u30fc\u30bf\u3092\u8fd4\u3057\u307e\u3059\u3002[1] \u4eca\u56de\u3082\u3001XY\u3092\u9001\u3063\u3066\u9001\u4fe1\u5074\u3092\u7d42\u4e86\u3055\u305b\u305f\u8a66\u884c\u3067\u306f\u30018\u30d0\u30a4\u30c8\u3092\u8997\u304f\u6307\u5b9a\u306b\u5bfe\u3057\u3066\u8fd4\u3063\u305f\u306e\u306f2\u30d0\u30a4\u30c8\u306eXY\u3067\u3057\u305f\u3002\u5148\u982d4\u30d0\u30a4\u30c8\u306b\u9577\u3055\u3092\u6301\u3064\u901a\u4fe1\u898f\u7d04\u306a\u3089\u30012\u30d0\u30a4\u30c8\u306e\u7d50\u679c\u3060\u3051\u3067\u9577\u3055\u3092\u89e3\u91c8\u3057\u3066\u306f\u3044\u3051\u307e\u305b\u3093\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u4f55\u3082\u5c4a\u3044\u3066\u304a\u3089\u305a\u76f8\u624b\u3082\u9001\u4fe1\u3092\u7d42\u3048\u3066\u3044\u306a\u3044\u5834\u5408\u3068\u3001\u9001\u4fe1\u7d42\u4e86\u5f8c\u306b\u672a\u8aad\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u5207\u3063\u305f\u5834\u5408\u306f\u5225\u3067\u3059\u3002\u975e\u30d6\u30ed\u30c3\u30ad\u30f3\u30b0\u306b\u3057\u305f\u4eca\u56de\u306ePython\u306e\u53d7\u4fe1\u5074\u3067\u306f\u3001\u524d\u8005\u306e\u8997\u304d\u8aad\u307f\u306fBlockingIOError\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u5f8c\u8005\u3067\u306f\u30011\u30d0\u30a4\u30c8\u3092\u8981\u6c42\u3057\u3066\u3082\u7a7a\u306ebytes\u304c\u8fd4\u308a\u307e\u3057\u305f\u3002\u3053\u3061\u3089\u304c\u3001\u3053\u306e\u30b9\u30c8\u30ea\u30fc\u30e0\u3067\u306eEOF\u3067\u3059\u3002<\/p>\n<p>\u76f8\u624b\u304c\u9001\u4fe1\u3092\u7d42\u3048\u3066\u3044\u3066\u3082\u3001XY\u304c\u672a\u8aad\u306a\u3089\u6700\u521d\u306epeek\u306fXY\u3092\u8fd4\u3057\u307e\u3059\u3002\u901a\u5e38\u306erecv\u3067\u305d\u308c\u3092\u53d7\u3051\u53d6\u3063\u305f\u5f8c\u3001\u6b21\u306epeek\u304c\u7a7a\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u7d42\u4e86\u306e\u6709\u7121\u3060\u3051\u3067\u306a\u304f\u3001\u307e\u3060\u8aad\u3093\u3067\u3044\u306a\u3044\u30c7\u30fc\u30bf\u304c\u6b8b\u3063\u3066\u3044\u308b\u304b\u3082\u7d50\u679c\u3078\u8868\u308c\u307e\u3059\u3002\u9577\u30550\u3092\u8981\u6c42\u3057\u305f\u547c\u51fa\u3057\u3084\u3001\u7a7a\u306eUDP\u30c7\u30fc\u30bf\u30b0\u30e9\u30e0\u307e\u3067\u3053\u306eEOF\u5224\u5b9a\u3078\u542b\u3081\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>MSG_PEEK\u3092\u9078\u3076\u5224\u65ad\u6750\u6599\u306f\u3001\u300c\u5148\u982d\u3092\u6b8b\u3059\u5fc5\u8981\u304c\u3042\u308b\u304b\u300d\u300c\u53d7\u4fe1\u3092\u9032\u3081\u308b\u8aad\u307f\u624b\u306f\u8ab0\u304b\u300d\u300c\u5224\u5b9a\u306b\u5fc5\u8981\u306a\u9577\u3055\u304c\u8db3\u308a\u306a\u3044\u3068\u304d\u3069\u3046\u3059\u308b\u304b\u300d\u3067\u3059\u3002\u5358\u306b\u53d7\u4fe1\u6e08\u307f\u306e\u60c5\u5831\u3092\u4f55\u5ea6\u3082\u53c2\u7167\u3057\u305f\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u53d7\u4fe1\u5f8c\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u53c2\u7167\u3059\u308b\u65b9\u6cd5\u3067\u3082\u76ee\u7684\u3092\u6e80\u305f\u305b\u307e\u3059\u3002OS\u5074\u306e\u5217\u306b\u6b8b\u3057\u305f\u3044\u7406\u7531\u304c\u3042\u308b\u3068\u304d\u306b\u3001\u8997\u304d\u8aad\u307f\u306e\u5f79\u5272\u304c\u306f\u3063\u304d\u308a\u3057\u307e\u3059\u3002<\/p>\n<h2>\u51fa\u5178\u30fb\u53c2\u8003\u8cc7\u6599<\/h2>\n<ul>\n<li>[1] <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/recv.2.html\">Linux man-pages 6.19 \u2014 recv(2)<\/a>\uff1aDESCRIPTION\u3001MSG_PEEK\u3001RETURN VALUE\u3002\u30da\u30fc\u30b8\u65e5\u4ed82025\u5e7410\u670829\u65e5\u3002\u901a\u5e38\u306e\u30d5\u30e9\u30b0\u8a2d\u5b9a\u3067\u306e\u8aac\u660e\u3092\u53c2\u7167\u3002<\/li>\n<li>[2] <a href=\"https:\/\/docs.python.org\/3.12\/library\/socket.html\">Python 3.12.15 documentation \u2014 socket<\/a>\uff1asocketpair\u3001recv\u3001dup\u3001setblocking\u3002\u547c\u51fa\u3057\u5148\u306eOS\u306b\u3088\u308b\u5dee\u304c\u3042\u308b\u70b9\u3092\u542b\u3080\u3002<\/li>\n<li>[3] <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/select.2.html\">Linux man-pages 6.19 \u2014 select(2)<\/a>\uff1aDESCRIPTION\u3001readfds\u3002\u6587\u66f8\u3068\u5b9f\u9a13\u7d50\u679c\u306f2026\u5e7410\u670825\u65e5\u306b\u78ba\u8a8d\u3002\u56f3\u306f\u4e0a\u8a18\u306e\u30ed\u30fc\u30ab\u30eb\u5b9f\u9a13\u304b\u3089\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u4fe1\u306e\u5148\u982d\u306b\u3042\u308b\u6570\u30d0\u30a4\u30c8\u3092\u898b\u3066\u3001\u3069\u306e\u51e6\u7406\u3078\u6e21\u3059\u304b\u6c7a\u3081\u305f\u3044\u3002\u305f\u3060\u3001\u305d\u306e\u6570\u30d0\u30a4\u30c8\u306f\u5f8c\u3067\u52d5\u304f\u51e6\u7406\u306b\u3082\u8aad\u3093\u3067\u307b\u3057\u3044\u3002\u53d7\u4fe1\u3092\u4e00\u5ea6\u9032\u3081\u3066\u3057\u307e\u3046\u3068\u3001\u8aad\u307f\u53d6\u3063\u305f\u90e8\u5206\u3092\u81ea\u5206\u3067\u4fdd\u5b58\u3057\u3066\u5f15\u304d\u6e21\u3059\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30bd\u30b1\u30c3\u30c8\u306e\u53d7\u4fe1\u306b\u6307\u5b9a\u3059\u308bMSG_ [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":1649,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[31],"tags":[335],"class_list":["post-1651","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-software","tag-msg-peek"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/quantumsea.net\/wp-content\/uploads\/2026\/10\/qs-msg-peek-receive-queue-20261025-featured-3d9624f133e7.png","_links":{"self":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1651"}],"version-history":[{"count":1,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1651\/revisions"}],"predecessor-version":[{"id":1652,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/posts\/1651\/revisions\/1652"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=\/wp\/v2\/media\/1649"}],"wp:attachment":[{"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quantumsea.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}