{"id":77587,"date":"2020-04-06T10:53:54","date_gmt":"2020-04-06T05:23:54","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=77587"},"modified":"2020-04-06T10:53:54","modified_gmt":"2020-04-06T05:23:54","slug":"java-socket-programming","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/","title":{"rendered":"Java Socket Programming &#8211; Upgrade your programming skills in Java"},"content":{"rendered":"<p>In our last Java tutorial, we discussed the Java URL class. In this tutorial, we will discuss the networking concept of Java programming, that is, Socket programming in Java along with its implementation.<\/p>\n<p>We will earn to establish a Java Socket Connection. We will discuss both client-side and server-side socket programming in Java.<\/p>\n<h3>Socket Programming in Java<\/h3>\n<p>Socket programming refers to communication between two nodes or applications running on different JRE (Java Runtime Environment). We use the socket programming in Java to connect the <strong>client<\/strong> program with the <strong>server<\/strong> program, or simply, connect a client and a server.<\/p>\n<p>Socket programming in Java can be either <strong>connection-oriented<\/strong> or <strong>connectionless<\/strong>. The package <strong>java.net<\/strong> is used for socket programming in Java. There are two classes in this package which are <strong>Socket<\/strong> class and <strong>ServerSocket<\/strong> class.<\/p>\n<p>Every server is a software program running on a specific system that listens to a specific port and waits for the requests from the client-side. For example, the Tomcat server running on the port number 8080 responds to the requests coming on this port number.<\/p>\n<p>The Java Socket Programming has two sections.<\/p>\n<ul>\n<li>Java Server Socket Program<\/li>\n<li>Java Client Socket Program<\/li>\n<\/ul>\n<p>The following diagram shows the Socket Programming process:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/java-socket-programming-process.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78060\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/java-socket-programming-process.jpg\" alt=\"\" width=\"700\" height=\"383\" \/><\/a><\/p>\n<h4>What is a Socket in Java?<\/h4>\n<p>A socket in Java is one of the nodes of a two-way communication link between the client and server programs running on the network. An endpoint or a node is a combination of an IP address and a port number.<\/p>\n<p>There is a port number for each socket so that the TCP layer can identify the application where to send the data.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/java-socket-programming.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-78061 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/04\/java-socket-programming.jpg\" alt=\"\" width=\"802\" height=\"420\" \/><\/a><\/p>\n<p>Now, let\u2019s discuss the two classes of java.net package in brief.<\/p>\n<h4>The java.net.Socket Class in Java<\/h4>\n<p>We use the Socket class to create the sockets for the client and server. The <strong>java.net.Socket<\/strong> class represents the socket. Both the client and the server programs use this socket to communicate with each other.<\/p>\n<p>There are some methods in the Socket class.<\/p>\n<h4>Methods of Socket Class<\/h4>\n<table class=\"tv-table-center\">\n<tbody>\n<tr>\n<td><b>S.N<\/b><\/td>\n<td><b>Method\u00a0<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>1<\/b><\/td>\n<td><span style=\"font-weight: 400\">public void connect(SocketAddress host, int timeout) throws IOException<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method connects the socket to the given input host.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>2<\/b><\/td>\n<td><span style=\"font-weight: 400\">public int getPort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method returns the port through which the socket is bound on the remote machine.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>3<\/b><\/td>\n<td><span style=\"font-weight: 400\">public int getLocalPort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method returns the port through which the socket is bound on the local machine.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>4<\/b><\/td>\n<td><span style=\"font-weight: 400\">public SocketAddress getRemoteSocketAddress()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method gives the address of the remote socket.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>5<\/b><\/td>\n<td><span style=\"font-weight: 400\">public InputStream getInputStream() throws IOException<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method returns the input stream of the socket.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>7<\/b><\/td>\n<td><span style=\"font-weight: 400\">public void close() throws IOException<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method closes the socket. Closing the socket makes it no longer available to connect it to any server.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>The java.net.ServerSocket Class in Java<\/h4>\n<p>The java.net.ServerSocket creates a server socket to obtain a port of the server and to listen to the client requests. The object of the ServerSocket class object helps to establish communication with the clients.<\/p>\n<h4>Methods of ServerSocket Class<\/h4>\n<table class=\"tv-table-center\">\n<tbody>\n<tr>\n<td><b>S.N.<\/b><\/td>\n<td><b>Method<\/b><\/td>\n<td><b> Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>1<\/b><\/td>\n<td><span style=\"font-weight: 400\">public int getLocalPort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method returns the port on which the server socket is listening to.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>2<\/b><\/td>\n<td><span style=\"font-weight: 400\">public Socket accept() throws IOException<\/span><\/td>\n<td><span style=\"font-weight: 400\">It returns the socket and establishes a connection between the server and the client.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>3<\/b><\/td>\n<td><span style=\"font-weight: 400\">public void setSoTimeout(int timeout)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method sets the time-out value for how long the server socket has to wait for a client during the accept() method.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>4<\/b><\/td>\n<td><span style=\"font-weight: 400\">public void bind(SocketAddress host, int backlog)<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method binds the socket to the specified server and port in the SocketAddress object.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>5<\/b><\/td>\n<td><span style=\"font-weight: 400\"> public synchronized void close()<\/span><\/td>\n<td><span style=\"font-weight: 400\">This method closes the object of the ServerSocket class.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Client-Side Socket Programming<\/h4>\n<p>For implementing client-side programming, we need to follow the below steps:<\/p>\n<ol>\n<li>Create a Socket<\/li>\n<li>Connect it to ServerSocket by specifying the IP address and the port number<\/li>\n<li>Get the reference of the OutputStream<\/li>\n<li>Attach this reference to OutputStreamWriter<\/li>\n<li>Write and close<\/li>\n<li>Get the reference of InputStream<\/li>\n<li>Attach this reference to InputStreamWriter<\/li>\n<li>Read and Buffer<\/li>\n<li>Parse, interpret and process it<\/li>\n<li>Close Connection<\/li>\n<\/ol>\n<h5>1. Creating a Socket<\/h5>\n<p>To create a Socket, we use the Socket class and create its object. We pass the IP address and port number of the Server inside the Socket.<\/p>\n<p>Here, we are using <strong>&#8220;localhost&#8221;<\/strong> because our server and the client applications are present on the same machine. For example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Socket s=new Socket(\"localhost\",6666);<\/pre>\n<h5>2. Connecting socket to ServerSocket<\/h5>\n<p>After creating a socket, we connect it to the ServerSocket by passing the IP address and the port number.<\/p>\n<h5>3. Get the reference of the OutputStream<\/h5>\n<p>Now, we get the reference of the OutputStream for writing the request.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DataOutputStream out = null;<\/pre>\n<h5>4. Attach this reference to OutputStreamWriter<\/h5>\n<p>Attach the reference of OutputStream to the OutputStreamWriter.<\/p>\n<h5>5. Write and close<\/h5>\n<p>With the reference of OutputStream, write the request and then close it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">out.write();<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">out.close();<\/pre>\n<h5>6. Get the reference of the InputStream<\/h5>\n<p>Now, we get the reference of the InputStream for reading the request.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DataInputStream input = null;<\/pre>\n<h5>7. Attach this reference to InputStreamWriter<\/h5>\n<p>Attach the reference of InputStream to the InputStreamReader.<\/p>\n<h5>8. Read and close<\/h5>\n<p>With the reference of InputStream, read the request a then close it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">input.readLine();<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">input.close();<\/pre>\n<h5>9. Close the connection<\/h5>\n<p>After interpreting and parsing, close the connection<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">socket .close();<\/pre>\n<h4>Server-Side Socket Programming<\/h4>\n<p>For implementing server-side programming, we need to follow the below steps:<\/p>\n<ol>\n<li>Create ServerSocket<\/li>\n<li>Bind it to a port number<\/li>\n<li>Put it into the listening mode<\/li>\n<li>Get the reference of InputStream<\/li>\n<li>Attach the reference to InputStreamReader<\/li>\n<li>Read and buffer<\/li>\n<li>Parse the request<\/li>\n<li>Prepare response<\/li>\n<li>Get the reference of OutputStream<\/li>\n<li>Attach the reference to OutputStreamReader<\/li>\n<li>Write the response<\/li>\n<li>Close Connection<\/li>\n<\/ol>\n<p><em><strong>Note:<\/strong> The 4th point only happens when there is a request from the client. Otherwise, the server ends at the 3rd stage only.<\/em><\/p>\n<h5>1. Creating a ServerSocket<\/h5>\n<p>To create a ServerSocket, we use the ServerSocket class and create its object.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ServerSocket server;<\/pre>\n<h5>2. Binding it to a port number<\/h5>\n<p>After creating the object, we bind it to a port number through which the client can request it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">server = new ServerSocket(port);<\/pre>\n<h5>3. Put it to the listening mode<\/h5>\n<p>Put the server into the listening mode so that it can listen to the requests coming from the client-side at the port number that we binded in the last step.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">server.accept();\n<\/pre>\n<h5>4. Get the reference of the OutputStream<\/h5>\n<p>Now, we get the reference of the OutputStream for writing the request.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DataOutputStream out = null;<\/pre>\n<h5>5. Attach this reference to OutputStreamWriter<\/h5>\n<p>Attach the reference of OutputStream to the OutputStreamWriter.<\/p>\n<h5>6. Write the response<\/h5>\n<p>With the reference of OutputSteam, write the response:<\/p>\n<h5>7. Close the connection<\/h5>\n<p>After writing the response, close the connection<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">socket .close();<\/pre>\n<p>Now as we know the process of both client and server-side, we will implement them with the help of Java code.<\/p>\n<h4>Implementing Socket Programming in Java<\/h4>\n<p><strong>Code for Server-side:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.techvidvan.socketprogramming;\n\/\/A Java program for a Server Side\nimport java.net.*;\nimport java.io.*;\npublic class ServerSide\n{\n  \/\/initialize socket and input stream\n  private Socket socket = null;\n  private ServerSocket server = null;\n  private DataInputStream in = null;\n  \/\/constructor with port\n  public ServerSide(int port)\n  {\n    \/\/starts server and waits for a connection\n    try\n    {\n      System.out.println(\"Server started at port 5100\");\n      System.out.println(\"Waiting for a client ...\");\n      socket = server.accept();\n      System.out.println(\"Client accepted\");\n      \/\/takes input from the client socket\n      in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));\n      String line = \" \";\n      \/\/reads message from client until \"Over\" is sent\n      while (!line.equals(\"Over\"))\n      {\n        try\n        {\n          line = in.readUTF();\n          System.out.println(line);\n        }\n        catch(IOException i)\n        {\n          System.out.println(i);\n        }\n      }\n      System.out.println(\"Closing connection\");\n      \/\/close connection\n      socket.close();\n      in.close();\n    }\n    catch(IOException i)\n    {\n      System.out.println(i);\n    }\n  }\n  public static void main(String args[]){\n    ServerSide server = new ServerSide(5100);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Server started at port 5230<br \/>\nWaiting for a client &#8230;<\/div>\n<p><strong>Code for Client-side:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.techvidvan.socketprogramming;\n\/\/A Java program for a ClientSide\nimport java.net.*;\nimport java.io.*;\npublic class ClientSide\n{\n  \/\/initialize socket and input output streams\n  private Socket socket = null;\n  private DataInputStream input = null;\n  private DataOutputStream out = null;\n  \/\/constructor to put ip address and port\n  @SuppressWarnings(\"deprecation\")\n  public ClientSide(String address, int port)\n  {\n    \/\/establish a connection\n    try\n    {\n      socket = new Socket(address, port);\n      System.out.println(\"Connected\");\n      \/\/takes input from terminal\n      input = new DataInputStream(System.in);\n      \/\/sends output to the socket\n      out = new DataOutputStream(socket.getOutputStream());\n    }\n    catch(UnknownHostException u)\n    {\n      System.out.println(u);\n    }\n    catch(IOException i)\n    {\n      System.out.println(i);\n    }\n    \/\/ string to read message from input\n    String line = \" \";\n    \/\/keep reading until \"Over\" is input\n    while (!line.equals(\"Over\"))\n    {\n      try\n      {\n        line = input.readLine();\n        out.writeUTF(line);\n      }\n      catch(IOException i)\n      {\n        System.out.println(i);\n      }\n    }\n    \/\/close the connection\n    try\n    {\n      input.close();\n      out.close();\n      socket.close();\n    }\n    catch(IOException i)\n    {\n      System.out.println(i);\n    }\n  }\n  public static void main(String args[])\n  {\n    ClientSide client = new ClientSide(\"localhost\", 5230);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Connected<\/div>\n<h5>Important Points<\/h5>\n<ul>\n<li>The server application makes the object of <strong>ServerSocket<\/strong> on port number 5230. Then, the server starts listening for client requests for port 5230.<\/li>\n<li>After that, the Server makes a<strong> Socket<\/strong> object to communicate with the client.<\/li>\n<li>The <strong>accept()<\/strong> method does not run unless the client program connects to the server.<\/li>\n<li>The <strong>getInputStream()<\/strong> method takes the input from the socket.<\/li>\n<li>The Server keeps receiving messages until the Client sends <strong>\u201cOver\u201d<\/strong>.<\/li>\n<li>In the end, we close the connection with the <strong>close()<\/strong> method. We close both the socket and the input stream.<\/li>\n<li>Compile both the Client and Server programs on your machine, and then, first, run the Server and then run the Client.<\/li>\n<\/ul>\n<h3>Summary<\/h3>\n<p>Socket Programming in Java is used to set the communication between the two nodes on the network. There are two important classes for Socket Programming in Java which is Socket and ServerSocket class. We covered various important methods of both the classes.<\/p>\n<p>At last, we implemented the socket programming by connecting the client code with the server code. This article will surely help you to build and sharpen your concepts in Java Socket Programming.<\/p>\n<p>Thank you for reading our article. Do share your feedback through the comment section below.<\/p>\n<p>Happy Learning \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last Java tutorial, we discussed the Java URL class. In this tutorial, we will discuss the networking concept of Java programming, that is, Socket programming in Java along with its implementation. We&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":78061,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[2221,2222,2223,2224,2225,2226,2227],"class_list":["post-77587","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-client-side-socket-programming","tag-java-socket-programming","tag-java-socket-programming-implementation","tag-java-socket-programming-methods","tag-server-side-socket-programming","tag-socket-programming-in-java","tag-socket-programming-in-java-with-example"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Socket Programming - Upgrade your programming skills in Java - TechVidvan<\/title>\n<meta name=\"description\" content=\"Java Socket Programming - In this article you will go through the 2 important classes of socket programming, methods &amp; will learn to implement them in Java.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Socket Programming - Upgrade your programming skills in Java - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Java Socket Programming - In this article you will go through the 2 important classes of socket programming, methods &amp; will learn to implement them in Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-06T05:23:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Socket Programming - Upgrade your programming skills in Java - TechVidvan","description":"Java Socket Programming - In this article you will go through the 2 important classes of socket programming, methods & will learn to implement them in Java.","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:\/\/techvidvan.com\/tutorials\/java-socket-programming\/","og_locale":"en_US","og_type":"article","og_title":"Java Socket Programming - Upgrade your programming skills in Java - TechVidvan","og_description":"Java Socket Programming - In this article you will go through the 2 important classes of socket programming, methods & will learn to implement them in Java.","og_url":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-04-06T05:23:54+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Java Socket Programming &#8211; Upgrade your programming skills in Java","datePublished":"2020-04-06T05:23:54+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/"},"wordCount":1300,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg","keywords":["Client-Side Socket Programming","Java Socket Programming","Java Socket Programming Implementation","Java Socket Programming Methods","Server-Side Socket Programming","Socket Programming in Java","Socket Programming in Java with example"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/","url":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/","name":"Java Socket Programming - Upgrade your programming skills in Java - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg","datePublished":"2020-04-06T05:23:54+00:00","description":"Java Socket Programming - In this article you will go through the 2 important classes of socket programming, methods & will learn to implement them in Java.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/04\/java-socket-programming.jpg","width":802,"height":420},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-socket-programming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java Socket Programming &#8211; Upgrade your programming skills in Java"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/77587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=77587"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/77587\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/78061"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=77587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=77587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=77587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}