{"id":86,"date":"2025-04-02T08:43:17","date_gmt":"2025-04-02T08:43:17","guid":{"rendered":"https:\/\/phuocloc.edu.vn\/?p=86"},"modified":"2025-04-02T08:43:17","modified_gmt":"2025-04-02T08:43:17","slug":"lap-trinh-mang","status":"publish","type":"post","link":"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/","title":{"rendered":"L\u1eadp tr\u00ecnh m\u1ea1ng"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#1_Tong_quan_ve_lap_trinh_mang\" title=\"1. T\u1ed5ng quan v\u1ec1 l\u1eadp tr\u00ecnh m\u1ea1ng\">1. T\u1ed5ng quan v\u1ec1 l\u1eadp tr\u00ecnh m\u1ea1ng<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#2_Cac_thanh_phan_co_ban\" title=\"2. C\u00e1c th\u00e0nh ph\u1ea7n c\u01a1 b\u1ea3n\">2. C\u00e1c th\u00e0nh ph\u1ea7n c\u01a1 b\u1ea3n<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#3_Mo_hinh_lap_trinh_mang\" title=\"3. M\u00f4 h\u00ecnh l\u1eadp tr\u00ecnh m\u1ea1ng\">3. M\u00f4 h\u00ecnh l\u1eadp tr\u00ecnh m\u1ea1ng<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#4_Cac_buoc_co_ban_trong_lap_trinh_mang\" title=\"4. C\u00e1c b\u01b0\u1edbc c\u01a1 b\u1ea3n trong l\u1eadp tr\u00ecnh m\u1ea1ng\">4. C\u00e1c b\u01b0\u1edbc c\u01a1 b\u1ea3n trong l\u1eadp tr\u00ecnh m\u1ea1ng<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#5_Cong_cu_va_ngon_ngu_ho_tro\" title=\"5. C\u00f4ng c\u1ee5 v\u00e0 ng\u00f4n ng\u1eef h\u1ed7 tr\u1ee3\">5. C\u00f4ng c\u1ee5 v\u00e0 ng\u00f4n ng\u1eef h\u1ed7 tr\u1ee3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/phuocloc.edu.vn\/index.php\/2025\/04\/02\/lap-trinh-mang\/#6_Ung_dung_thuc_tien\" title=\"6. \u1ee8ng d\u1ee5ng th\u1ef1c ti\u1ec5n\">6. \u1ee8ng d\u1ee5ng th\u1ef1c ti\u1ec5n<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"1_Tong_quan_ve_lap_trinh_mang\"><\/span><strong>1. T\u1ed5ng quan v\u1ec1 l\u1eadp tr\u00ecnh m\u1ea1ng<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>L\u1eadp tr\u00ecnh m\u1ea1ng l\u00e0 vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng, h\u1ec7 th\u1ed1ng c\u00f3 kh\u1ea3 n\u0103ng giao ti\u1ebfp qua m\u1ea1ng m\u00e1y t\u00ednh. C\u00e1c m\u1ea1ng n\u00e0y bao g\u1ed3m:<\/p>\n<ul>\n<li><strong>M\u1ea1ng n\u1ed9i b\u1ed9 (LAN):<\/strong> Ph\u1ea1m vi nh\u1ecf nh\u01b0 v\u0103n ph\u00f2ng, nh\u00e0 ri\u00eang.<\/li>\n<li><strong>M\u1ea1ng di\u1ec7n r\u1ed9ng (WAN):<\/strong> K\u1ebft n\u1ed1i gi\u1eefa nhi\u1ec1u m\u1ea1ng, bao g\u1ed3m Internet.<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Cac_thanh_phan_co_ban\"><\/span><strong>2. C\u00e1c th\u00e0nh ph\u1ea7n c\u01a1 b\u1ea3n<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Giao th\u1ee9c m\u1ea1ng:<\/strong> L\u00e0 c\u00e1c quy t\u1eafc, chu\u1ea9n m\u1ef1c \u0111\u1ec3 c\u00e1c thi\u1ebft b\u1ecb giao ti\u1ebfp v\u1edbi nhau. C\u00e1c giao th\u1ee9c ph\u1ed5 bi\u1ebfn:\n<ul>\n<li><strong>TCP\/IP:<\/strong> Giao th\u1ee9c truy\u1ec1n th\u00f4ng c\u01a1 b\u1ea3n c\u1ee7a Internet, \u0111\u1ea3m b\u1ea3o vi\u1ec7c truy\u1ec1n d\u1eef li\u1ec7u \u1ed5n \u0111\u1ecbnh.<\/li>\n<li><strong>UDP:<\/strong> Truy\u1ec1n d\u1eef li\u1ec7u nhanh nh\u01b0ng kh\u00f4ng \u0111\u1ea3m b\u1ea3o.<\/li>\n<li><strong>HTTP\/HTTPS:<\/strong> Truy\u1ec1n t\u1ea3i d\u1eef li\u1ec7u web.<\/li>\n<li><strong>FTP:<\/strong> Chuy\u1ec3n t\u1eadp tin.<\/li>\n<li><strong>SMTP:<\/strong> G\u1eedi email.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Socket:<\/strong> C\u1ed5ng giao ti\u1ebfp gi\u1eefa hai thi\u1ebft b\u1ecb trong m\u1ea1ng. Ch\u00fang c\u00f3 hai lo\u1ea1i:\n<ul>\n<li><strong>Socket h\u01b0\u1edbng k\u1ebft n\u1ed1i (TCP):<\/strong> \u0110\u1ea3m b\u1ea3o d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c truy\u1ec1n \u0111\u1ea7y \u0111\u1ee7, kh\u00f4ng m\u1ea5t m\u00e1t.<\/li>\n<li><strong>Socket kh\u00f4ng k\u1ebft n\u1ed1i (UDP):<\/strong> Nhanh nh\u01b0ng kh\u00f4ng \u0111\u1ea3m b\u1ea3o \u0111\u1ea7y \u0111\u1ee7 d\u1eef li\u1ec7u.<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u0110\u1ecba ch\u1ec9 IP v\u00e0 c\u1ed5ng:<\/strong>\n<ul>\n<li><strong>IP:<\/strong> \u0110\u1ecbnh danh thi\u1ebft b\u1ecb trong m\u1ea1ng.<\/li>\n<li><strong>Port:<\/strong> \u0110\u1ecbnh danh \u1ee9ng d\u1ee5ng\/ti\u1ebfn tr\u00ecnh trong thi\u1ebft b\u1ecb.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"3_Mo_hinh_lap_trinh_mang\"><\/span><strong>3. M\u00f4 h\u00ecnh l\u1eadp tr\u00ecnh m\u1ea1ng<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>C\u00f3 hai m\u00f4 h\u00ecnh c\u01a1 b\u1ea3n:<\/p>\n<ol start=\"1\">\n<li><strong>M\u00f4 h\u00ecnh Client-Server:<\/strong>\n<ul>\n<li><strong>Client:<\/strong> G\u1eedi y\u00eau c\u1ea7u (request) \u0111\u1ebfn Server.<\/li>\n<li><strong>Server:<\/strong> X\u1eed l\u00fd y\u00eau c\u1ea7u v\u00e0 tr\u1ea3 l\u1eddi (response).<\/li>\n<li>V\u00ed d\u1ee5: Tr\u00ecnh duy\u1ec7t web l\u00e0 client, website l\u00e0 server.<\/li>\n<\/ul>\n<\/li>\n<li><strong>M\u00f4 h\u00ecnh Peer-to-Peer (P2P):<\/strong>\n<ul>\n<li>C\u00e1c thi\u1ebft b\u1ecb v\u1eeba \u0111\u00f3ng vai tr\u00f2 client v\u1eeba l\u00e0 server, giao ti\u1ebfp tr\u1ef1c ti\u1ebfp v\u1edbi nhau.<\/li>\n<li>V\u00ed d\u1ee5: \u1ee8ng d\u1ee5ng chia s\u1ebb t\u1ec7p Torrent.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"4_Cac_buoc_co_ban_trong_lap_trinh_mang\"><\/span><strong>4. C\u00e1c b\u01b0\u1edbc c\u01a1 b\u1ea3n trong l\u1eadp tr\u00ecnh m\u1ea1ng<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol start=\"1\">\n<li><strong>X\u00e2y d\u1ef1ng socket:<\/strong>\n<ul>\n<li>Client v\u00e0 server t\u1ea1o socket \u0111\u1ec3 giao ti\u1ebfp.<\/li>\n<\/ul>\n<\/li>\n<li><strong>K\u1ebft n\u1ed1i (ch\u1ec9 v\u1edbi TCP):<\/strong>\n<ul>\n<li>Server m\u1edf c\u1ed5ng l\u1eafng nghe.<\/li>\n<li>Client k\u1ebft n\u1ed1i \u0111\u1ebfn server.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Trao \u0111\u1ed5i d\u1eef li\u1ec7u:<\/strong>\n<ul>\n<li>Client g\u1eedi y\u00eau c\u1ea7u \u2192 Server nh\u1eadn v\u00e0 x\u1eed l\u00fd \u2192 Server tr\u1ea3 ph\u1ea3n h\u1ed3i.<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u0110\u00f3ng k\u1ebft n\u1ed1i:<\/strong> Ho\u00e0n th\u00e0nh giao ti\u1ebfp.<\/li>\n<\/ol>\n<div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"5_Cong_cu_va_ngon_ngu_ho_tro\"><\/span><strong>5. C\u00f4ng c\u1ee5 v\u00e0 ng\u00f4n ng\u1eef h\u1ed7 tr\u1ee3<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>C\u00e1c ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh ph\u1ed5 bi\u1ebfn:<\/p>\n<ul>\n<li><strong>Python:<\/strong> V\u1edbi th\u01b0 vi\u1ec7n <code>socket<\/code>, <code>asyncio<\/code>, <code>requests<\/code>.<\/li>\n<li><strong>Java:<\/strong> V\u1edbi c\u00e1c API nh\u01b0 <code>java.net<\/code> ho\u1eb7c <code>HttpClient<\/code>.<\/li>\n<li><strong>C\/C++:<\/strong> S\u1eed d\u1ee5ng th\u01b0 vi\u1ec7n socket truy\u1ec1n th\u1ed1ng.<\/li>\n<li><strong>JavaScript:<\/strong> D\u00f9ng trong l\u1eadp tr\u00ecnh web v\u1edbi giao th\u1ee9c nh\u01b0 WebSocket.<\/li>\n<li><strong>Go:<\/strong> Chuy\u00ean v\u1ec1 c\u00e1c \u1ee9ng d\u1ee5ng m\u1ea1ng hi\u1ec7u n\u0103ng cao.<\/li>\n<\/ul>\n<div><\/div>\n<h3><span class=\"ez-toc-section\" id=\"6_Ung_dung_thuc_tien\"><\/span><strong>6. \u1ee8ng d\u1ee5ng th\u1ef1c ti\u1ec5n<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>X\u00e2y d\u1ef1ng h\u1ec7 th\u1ed1ng web (HTTP server, RESTful API).<\/li>\n<li>T\u1ea1o \u1ee9ng d\u1ee5ng chat (nh\u01b0 Messenger, WhatsApp).<\/li>\n<li>Qu\u1ea3n l\u00fd h\u1ec7 th\u1ed1ng m\u1ea1ng (gi\u00e1m s\u00e1t, ki\u1ec3m tra k\u1ebft n\u1ed1i).<\/li>\n<li>Truy\u1ec1n ph\u00e1t \u0111a ph\u01b0\u01a1ng ti\u1ec7n (streaming video\/audio).<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. T\u1ed5ng quan v\u1ec1 l\u1eadp tr\u00ecnh m\u1ea1ng L\u1eadp tr\u00ecnh m\u1ea1ng l\u00e0 vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng, h\u1ec7 th\u1ed1ng c\u00f3 kh\u1ea3 n\u0103ng giao ti\u1ebfp qua m\u1ea1ng m\u00e1y t\u00ednh. C\u00e1c m\u1ea1ng n\u00e0y bao g\u1ed3m: M\u1ea1ng n\u1ed9i b\u1ed9 (LAN): Ph\u1ea1m vi nh\u1ecf&#8230;<\/p>\n","protected":false},"author":1,"featured_media":87,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,25,20],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cong-nghe-thong-tin","category-lap-trinh-mang","category-mang-may-tinh"],"_links":{"self":[{"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":1,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions\/88"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/media\/87"}],"wp:attachment":[{"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phuocloc.edu.vn\/index.php\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}