[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-347323-105":59,"doc-detail-347323-en":131},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":124,"head_meta":126,"extra_data":128,"updated_unix":130},105,"en","beejs-guide-to-network-programming-using-internet-sockets","Beej’s Guide to Network Programming - Using Internet Sockets","","Beej’s Guide to Network Programming introduces Internet socket programming with a practical, systems-oriented approach. It explains what sockets are, covers IPv4 and IPv6 basics including addresses, subnets, and port numbers, and shows how byte order and struct data packing affect network exchange. The guide then walks through core system calls such as getaddrinfo, socket, bind, connect, listen, accept, send/recv, and close/shutdown, followed by client-server patterns, polling/select for multiplexing, and handling partial sends.",{"@graph":69,"@context":123},[70,84,106],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/beejs-guide-to-network-programming-using-internet-sockets/347323/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/beejs-guide-to-network-programming-using-internet-sockets/347323.png","ImageObject",300,407,{"name":92,"@type":93},"Alex Sinclair","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-25","2026-09-22",true,{"@type":102,"interactionType":103,"userInteractionCount":105},"InteractionCounter",{"@type":104},"ViewAction",12,{"@type":107,"mainEntity":108},"FAQPage",[109,115,119],{"name":110,"@type":111,"acceptedAnswer":112},"What prerequisites does this guide target for socket programming?","Question",{"text":113,"@type":114},"The guide addresses readers who may find socket programming difficult to derive from man pages and aims to provide a clearer, more direct learning path.","Answer",{"name":116,"@type":111,"acceptedAnswer":117},"Which topics are covered when moving from IPv4 to IPv6?",{"text":118,"@type":114},"It includes fundamentals needed for the transition, building on address concepts and associated networking mechanics before introducing IPv6.",{"name":120,"@type":111,"acceptedAnswer":121},"What core system calls does the guide cover for setting up network communication?",{"text":122,"@type":114},"It walks through getaddrinfo, socket, bind, connect, listen, accept, send/recv, sendto/recvfrom, and also close and shutdown, describing the role each plays.","https://schema.org",{"og:url":83,"og:type":125,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":127,"canonical":83},"index,follow",{"doc_id":129,"site_id":62},347323,1790377005,{"code":4,"msg":5,"data":132},{"doc_id":129,"user_id":133,"nickname":92,"user_avatar":134,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":135,"file_id":136,"file_url":137,"file_type":138,"file_size":139,"view_count":105,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":140,"language":141,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":142,"faqs":143,"seo_title":144,"seo_description":67,"update_tm":145,"read_time":146,"preview_page_count":147,"preview_urls":148},1099523882182,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","Beej’s Guide to Network Programming  \nUsing Internet Sockets  \nBrian “Beej Jorgensen” Hall  \nv3.3.2, Copyright © April 18, 2026  \nContents  \n1 Intro 1  \n1.1 Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1  \n1.2 Platform and Compiler ..................................... 1  \n1.3 Official Homepage and Books For Sale ............................ 1  \n1.4 Note for Solaris/SunOS/illumos Programmers ........................ 2  \n1.5 Note for Windows Programmers ................................ 2  \n1.6 Email Policy ........................................... 4  \n1.7 Mirroring ............................................. 4  \n1.8 Note for Translators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4  \n1.9 Copyright, Distribution, and Legal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5  \n1. 10 Dedication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5  \n1.11 Publishing Information ..................................... 5  \n2 What is a socket? 6  \n2.1 Two Types of Internet Sockets ................................. 6  \n2.2 Low level Nonsense and Network Theory ........................... 8  \n3 IP Addresses,  struct s, and Data Munging 10  \n3.1 IP Addresses, versions 4 and 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10  \n3.1. 1 Subnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11  \n3.1. 2 Port Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12  \n3.2 Byte Order ............................................ 12  \n3.3  struct s ............................................. 14  \n3.4 IP Addresses, Part Deux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16  \n3.4.1 Private (Or Disconnected) Networks .......................... 17  \n4 Jumping from IPv4 to IPv6 19  \n5 System Calls or Bust 21  \n5.1  getaddrinfo()—Prepare to launch! ............................. 21  \n5.2  socket()—Get the File Descriptor! .............................. 25  \n5.3  bind()—What port am I on? ................................. 26  \n5.4  connect()—Hey, you! ..................................... 27  \n5.5  listen()—Will somebody please call me? .......................... 28  \n5.6  accept()—“Thank you for calling port 3490 .” ........................ 29  \n5.7  send()  and recv()—Talk to me, baby! ........................... 30  \n5.8  sendto()  and recvfrom()—Talk to me, DGRAM-style .................. 32  \n5.9  close()  and shutdown()—Get outta my face! ....................... 32  \n5.10  getpeername()—Who are you? ................................ 33  \n5.11  gethostname()—Who am I? .................................. 34  \n6 Client-Server Background 35  \nCONTENTS ii  \n6.1 A Simple Stream Server ..................................... 35  \n6.2 A Simple Stream Client ..................................... 38  \n6.3 Datagram Sockets ........................................ 41  \n7 Slightly Advanced Techniques 45  \n7.1 Blocking ............................................. 45  \n7.2  poll()—Synchronous I/O Multiplexing ........................... 46  \n7.3  select()—Synchronous I/O Multiplexing, Old School ................... 53  \n7.4 Handling Partial send() s ................................... 61  \n7.5 Serialization—How to Pack Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62  \n7.6 Son of Data Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76  \n7.7 Broadcast Packets—Hello, World! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77  \n8 Common Questions 81  \n9 Man Pages 87  \n9.1  accept()  ............................................ 88  \n9.2  bind()  ............................................. 89  \n9.3  connect()  ........................................... 91  \n9.4  close()  ............................................. 92  \n9.5  getaddrinfo() , freea","cbCainIQ8DIvPQSl","https://ap.wps.com/l/cbCainIQ8DIvPQSl","pdf",653968,134,"English","# Intro\n## Audience\n## Platform and Compiler\n## What is a socket?\n# IP Addresses, struct s, and Data Munging\n## IP Addresses, versions 4 and 6\n## Subnets and Port Numbers\n# Jumping from IPv4 to IPv6\n# System Calls or Bust\n## getaddrinfo(), socket(), bind(), connect()\n## listen(), accept(), send()/recv()\n# Client-Server Background\n## A Simple Stream Server\n## A Simple Stream Client\n# Slightly Advanced Techniques\n## Blocking\n## poll() and select()\n## Serialization and Encapsulation\n# Common Questions\n# Man Pages\n## accept(), bind(), connect(), close()\n## getaddrinfo(), gethostname(), getpeername()\n## htons()/htonl()/ntohs()/ntohl()\n## inet_ntop()/inet_pton()\n## listen(), perror()/strerror(), poll()/recv()/select()\n## setsockopt()/getsockopt(), send()/sendto(), shutdown(), socket()","[{\"question\":\"What prerequisites does this guide target for socket programming?\",\"answer\":\"The guide addresses readers who may find socket programming difficult to derive from man pages and aims to provide a clearer, more direct learning path.\"},{\"question\":\"Which topics are covered when moving from IPv4 to IPv6?\",\"answer\":\"It includes fundamentals needed for the transition, building on address concepts and associated networking mechanics before introducing IPv6.\"},{\"question\":\"What core system calls does the guide cover for setting up network communication?\",\"answer\":\"It walks through getaddrinfo, socket, bind, connect, listen, accept, send/recv, sendto/recvfrom, and also close and shutdown, describing the role each plays.\"}]","Beej’s Guide to Network Programming - Using Internet Sockets | PDF",1790066394,338,14,[149,153,157,161,165,169,173,177,181,185,189,194,198,203],{"page_no":8,"url":150,"width":151,"height":152},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/39a0fd0fed0859f269790c701694d040.webp",983,1272,{"page_no":14,"url":154,"width":155,"height":156},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/d2632d8f00356f50b7595180f1a8bdb8.webp",982,1270,{"page_no":81,"url":158,"width":159,"height":160},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/16c9f3ddbf68226d77129f2eddbb949c.webp",981,1269,{"page_no":19,"url":162,"width":163,"height":164},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/25b595d9e9eb1dd3ffd674c8e6d9978b.webp",980,1268,{"page_no":24,"url":166,"width":167,"height":168},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/4336141c1b300cc36711141ad816a2f0.webp",979,1267,{"page_no":29,"url":170,"width":171,"height":172},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/0971e11c4500fba08f49f37251a022d8.webp",978,1265,{"page_no":34,"url":174,"width":175,"height":176},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/360242ce487348f2a2cc92b5b7d1501c.webp",977,1264,{"page_no":39,"url":178,"width":179,"height":180},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/25f1ae39ed4bc88194a0e02b5cd36b32.webp",976,1263,{"page_no":44,"url":182,"width":183,"height":184},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/595910e137e71ad49523bd3ecaf59e04.webp",975,1261,{"page_no":52,"url":186,"width":187,"height":188},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/b871ab8636ab8887711353033edb6f8e.webp",974,1260,{"page_no":190,"url":191,"width":192,"height":193},11,"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/594305019cfae3564ab51c47b3389f11.webp",973,1259,{"page_no":105,"url":195,"width":196,"height":197},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/063a038eca429f1c9c9b5b3df466b563.webp",972,1257,{"page_no":199,"url":200,"width":201,"height":202},13,"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/5320994750e296983795bf76dbe3bbbc.webp",971,1256,{"page_no":147,"url":204,"width":205,"height":206},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/73182d690e7298fdc440273a816af034.webp",970,1255]