

{"id":14917,"date":"2018-05-09T08:30:51","date_gmt":"2018-05-09T03:00:51","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=14917"},"modified":"2026-04-24T16:09:11","modified_gmt":"2026-04-24T10:39:11","slug":"python-network-programming","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-network-programming\/","title":{"rendered":"Python Network Programming &#8211; What is Socket Programming in Python"},"content":{"rendered":"<h3>Python Socket Programming<\/h3>\n<p><span style=\"font-weight: 400\">In this<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-tutorial-for-beginners\/\"> Python<\/a><\/strong> tutorial, we are going to study Python Network Programming. With Python, we can access an operating system\u2019s socket support. This will let you implement clients and servers for connection-oriented and connectionless protocols. Moreover, this Python 3 tutorial gave you an understanding of Socket programming in Python with vocabulary and examples. Along with this, we will learn the Python socket Module and Python socket Methods.<\/span><\/p>\n<p><span style=\"font-weight: 400\">So, let\u2019s begin networking in Python 3.<\/span><\/p>\n<div id=\"attachment_14919\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-14919\" class=\"wp-image-14919 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg\" alt=\"Python 3 Network Programming\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-14919\" class=\"wp-caption-text\">Python 3 Network Programming<\/p><\/div>\n<h3><span style=\"font-weight: 400\">Introduction to Python Network Programming<\/span><\/h3>\n<p><strong>In Python, there are 2 levels of networking programs:<\/strong><\/p>\n<ul>\n<li><strong>Low- level access:<\/strong> Here, you can access the basic socket support of an operating system.<\/li>\n<li><strong>High- level access:<\/strong> Protocols such as HTTPS, FTP, etc. can be implemented at a higher level.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">To learn Python Network Programming, first begin with Python Socket Programming.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Consider a bidirectional communication channel. Its end-points are what we call sockets. Sockets may communicate in one of the following ways:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400\">Within a process<\/span><\/li>\n<li><span style=\"font-weight: 400\">Between processes on the same machine<\/span><\/li>\n<li><span style=\"font-weight: 400\">Between processes on different machines<\/span><\/li>\n<\/ol>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-closure\/\">Learn Python Closure \u2013 Nested Functions and Nonlocal Variables<\/a><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">Python Socket Vocabulary<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Let\u2019s take a look at all we talk about when we talk about sockets.<\/span><\/p>\n<div id=\"attachment_14920\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-14920\" class=\"wp-image-14920 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01.jpg\" alt=\"Python 3 Network Programming\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Socket-Vocabulary-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-14920\" class=\"wp-caption-text\">Python 3 Network Programming- Python Socket vocabulary<\/p><\/div>\n<h4><span style=\"font-weight: 400\">a. Domain<\/span><\/h4>\n<p><span style=\"font-weight: 400\">For transport, we use protocols like AF_INET, PF_INET, PF_UNIX, and PF_X25, among others. This family of protocols is the domain.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">b. Type<\/span><\/h4>\n<p><span style=\"font-weight: 400\">Communication between two endpoints may typically be of type SOCK_DGRAM for connectionless protocols and SOC_STREAM for connection-oriented ones.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">c. Protocol<\/span><\/h4>\n<p><span style=\"font-weight: 400\">This identifies the protocol used within a domain and type. This is typically zero.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">d. Port<\/span><\/h4>\n<p><span style=\"font-weight: 400\">Servers listen to one or more ports for client calls. But what values can a port take? A Fixnum port number, a service name, or a string holding the port number.<\/span><\/p>\n<h4><span style=\"font-weight: 400\">e. Hostname<\/span><\/h4>\n<p><span style=\"font-weight: 400\">A hostname is what identifies a network interface. This can be a string holding a hostname, a dotted-quad address, or an IPv6 address. This can also be a zero-length string, an Integer, or a string \u201c&lt;broadcast&gt;\u201d.<\/span><br \/>\n<span style=\"font-weight: 400\">We can implement a socket over different channel types- like TCP and UDP. We can also use the socket library to handle transport.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-modules-vs-packages\/\">Read Python Modules Vs Packages<\/a><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">Python Socket Module<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Let\u2019s first import the Python socket module for this.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import socket\r\n&gt;&gt;&gt;<\/pre>\n<p><span style=\"font-weight: 400\">Now, we can use the socket.socket(socket_family,socket_type,protocol=0) function to create a socket.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; mysocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\r\n&gt;&gt;&gt; mysocket<\/pre>\n<p>&lt;socket.socket fd=1524, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0&gt;<\/p>\n<p><span style=\"font-weight: 400\">Here, socket_family may take one of the values AF_UNIX and AF_INET. socket_type may be SOCK_STREAM or SOCK_DGRAM. protocol defaults to zero.<\/span><\/p>\n<h3><span style=\"font-weight: 400\">Python Socket Methods<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Now, we may call any of these methods on this object we just created.<\/span><\/p>\n<div id=\"attachment_15393\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15393\" class=\"wp-image-15393 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01.jpg\" alt=\"Python Network Programming\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Python-Socket-Methods-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15393\" class=\"wp-caption-text\">Python Network Programming- Python Socket Methods<\/p><\/div>\n<h4><strong>a. Server Socket Methods in Python<\/strong><\/h4>\n<p><strong>i. s.bind() method in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This binds the address to the socket. This address holds the hostname and the port number pair.<\/span><\/p>\n<p><strong>ii. s.listen() method in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This starts the TCP listener.<\/span><\/p>\n<p><strong>iii. s.accept() method in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This method passively accepts the TCP client connection and blocks until the connection arrives.<\/span><\/p>\n<h4><strong>b. Client socket methods in Python<\/strong><\/h4>\n<h4><strong>i. s.connect() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This actively initiates a TCP server connection.<\/span><br \/>\n<span style=\"font-weight: 400\">And\u00a0<\/span><\/p>\n<h3><span style=\"font-weight: 400\"><strong>c. General socket methods in Python<\/strong><\/span><\/h3>\n<h4><strong>i. s.send() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This sends the TCP message.<\/span><\/p>\n<h4><strong>ii. s.sendto() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This sends the UDP message.<\/span><\/p>\n<h4><strong>iii. s.recv() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This receives the TCP message.<\/span><\/p>\n<h4><strong>iv. s.recvfrom() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This receives the UDP message.<\/span><\/p>\n<h4><strong>v. s.close() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This method closes the socket.<\/span><\/p>\n<h4><strong>vi. socket.gethostname() methods in Python<\/strong><\/h4>\n<p><span style=\"font-weight: 400\">This returns the hostname.<\/span><\/p>\n<p><strong>a. Examples-Server<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Let\u2019s first try implementing a simple server.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import socket\r\n&gt;&gt;&gt; myserver=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\r\n&gt;&gt;&gt; host=socket.gethostname()\r\n&gt;&gt;&gt; port=9999\r\n&gt;&gt;&gt; myserver.bind((host,port))\r\n&gt;&gt;&gt; myserver.listen(5)  #This asks for permission on Windows\r\n&gt;&gt;&gt; while True:\r\n      myclient,addr=myserver.accept()\r\n      print(f\"Connected to {str(addr)}\")\r\n      myclient.send(msg.encode(\"ascii\"))\r\n      myclient.close()<\/pre>\n<p><strong>b.\u00a0Examples-Client<\/strong><\/p>\n<p><span style=\"font-weight: 400\">Now, let\u2019s try implementing a client.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import socket\r\n&gt;&gt;&gt; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\r\n&gt;&gt;&gt; host=socket.gethostname()\r\n&gt;&gt;&gt; port=9999\r\n&gt;&gt;&gt; s.connect((host,port))\r\n&gt;&gt;&gt; msg=s.recv(1024)\r\n&gt;&gt;&gt; s.close()\r\n&gt;&gt;&gt; print(msg.decode(\"ascii\"))<\/pre>\n<h3><span style=\"font-weight: 400\">Other Internet Modules<\/span><\/h3>\n<p><span style=\"font-weight: 400\">There are some other modules. Now, let us work with networks:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400\"><strong> httplib, urllib, xmlrpclib-<\/strong> For the HTTP protocol, dealing with web pages, on port 80.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> nntplib-<\/strong> For protocol NNTP, dealing with Usenet news, on port 119.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> ftplib, urllib<\/strong>&#8211; For protocol FTP, dealing with file transfers, on port 20.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> smtplib<\/strong>&#8211; For protocol SMTP, dealing with sending email, on port 25.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> poplib-<\/strong> For protocol POP3, for fetching email, on port 110.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> imaplib-<\/strong> For protocol IMAP4, for fetching email, on port 143.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> telnetlib-<\/strong> For the protocol Telnet, for dealing with command lines, on port 23.<\/span><\/li>\n<li><span style=\"font-weight: 400\"><strong> gopherlib, urllib<\/strong>&#8211; For protocol Gopher, for dealing with document transfers, on port 70.<\/span><\/li>\n<\/ol>\n<h3><span style=\"font-weight: 400\">Exceptions Thrown by Socket Programming in Python<\/span><\/h3>\n<p><span style=\"font-weight: 400\">The socket module may throw one of the following exceptions:<\/span><\/p>\n<p><strong>a. exception socket.error in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This represents a socket-related error.<\/span><\/p>\n<p><strong>b. exception socket.herror in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This represents an address-related error.<\/span><\/p>\n<p><strong>c. exception socket.gaierror in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This represents an address-related error.<\/span><\/p>\n<p><strong>d. exception socket.timeout in Python<\/strong><\/p>\n<p><span style=\"font-weight: 400\">This occurs when a socket times out.<\/span><\/p>\n<p>So, this was all about Python Network Programming in today&#8217;s Python Tutorial. Hope you like our explanation.<\/p>\n<h3><span style=\"font-weight: 400\">Conclusion<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Hence, we discussed the basics of Python Network programming. Basically, an introduction to Python Socket Programming and Python Socket Vocabulary. Moreover, we discussed the Socket Module and Socket methods with the help of examples. Lastly, we saw other internet Modules and Exceptions thrown by Python Socket. Furthermore, if you have any queries, feel free to ask in the comments section.\u00a0<\/span><br \/>\n<a href=\"https:\/\/docs.python.org\/3\/howto\/sockets.html\">For reference<\/a><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1955,&quot;href&quot;:&quot;https:\\\/\\\/docs.python.org\\\/3\\\/howto\\\/sockets.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251010010608\\\/https:\\\/\\\/docs.python.org\\\/3\\\/howto\\\/sockets.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 13:22:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-24 04:17:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-02 11:55:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-11 15:25:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-19 22:26:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-24 15:23:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-29 14:05:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-06 16:54:15&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-10 10:30:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 10:10:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 23:33:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 23:56:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-05 08:10:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 13:59:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 07:34:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-24 09:04:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-03 23:36:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-29 21:23:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-12 10:57:31&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-12 10:57:31&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Socket Programming In this Python tutorial, we are going to study Python Network Programming. With Python, we can access an operating system\u2019s socket support. This will let you implement clients and servers for&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":14919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[9051,10333,10335,10341,10344,10718,10845,10846,10847,10903,12972],"class_list":["post-14917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-networking-in-python-3","tag-python","tag-python-3","tag-python-3-network-programming","tag-python-3-tutorial","tag-python-network-programming","tag-python-socket-methods","tag-python-socket-programming","tag-python-socket-vocabulary","tag-python-tutorial","tag-socket-module"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Network Programming - What is Socket Programming in Python - DataFlair<\/title>\n<meta name=\"description\" content=\"Python network Programming, What is Socket Programming in Python ,Python Socket Vocabulary,Socket Module,Python Socket Methods,example,socket Exceptions\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-network-programming\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Network Programming - What is Socket Programming in Python - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python network Programming, What is Socket Programming in Python ,Python Socket Vocabulary,Socket Module,Python Socket Methods,example,socket Exceptions\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-network-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-09T03:00:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T10:39:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Network Programming - What is Socket Programming in Python - DataFlair","description":"Python network Programming, What is Socket Programming in Python ,Python Socket Vocabulary,Socket Module,Python Socket Methods,example,socket Exceptions","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-network-programming\/","og_locale":"en_US","og_type":"article","og_title":"Python Network Programming - What is Socket Programming in Python - DataFlair","og_description":"Python network Programming, What is Socket Programming in Python ,Python Socket Vocabulary,Socket Module,Python Socket Methods,example,socket Exceptions","og_url":"https:\/\/data-flair.training\/blogs\/python-network-programming\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-09T03:00:51+00:00","article_modified_time":"2026-04-24T10:39:11+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Network Programming &#8211; What is Socket Programming in Python","datePublished":"2018-05-09T03:00:51+00:00","dateModified":"2026-04-24T10:39:11+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/"},"wordCount":906,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg","keywords":["Networking in Python 3","Python","Python 3","Python 3 network Programming","Python 3 tutorial","python network programming","Python Socket Methods","Python Socket Programming","Python Socket Vocabulary","python tutorial","Socket Module"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-network-programming\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/","url":"https:\/\/data-flair.training\/blogs\/python-network-programming\/","name":"Python Network Programming - What is Socket Programming in Python - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg","datePublished":"2018-05-09T03:00:51+00:00","dateModified":"2026-04-24T10:39:11+00:00","description":"Python network Programming, What is Socket Programming in Python ,Python Socket Vocabulary,Socket Module,Python Socket Methods,example,socket Exceptions","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-network-programming\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Networking-in-Python-3-01.jpg","width":1200,"height":628,"caption":"Python 3 Network Programming"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-network-programming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Network Programming &#8211; What is Socket Programming in Python"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/14917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=14917"}],"version-history":[{"count":7,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/14917\/revisions"}],"predecessor-version":[{"id":147851,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/14917\/revisions\/147851"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/14919"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=14917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=14917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=14917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}