<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/rss/styles.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Arunangshu Biswas | Software Engineer</title><description>A software-engineer with a graduate degree and a passion for crafting solutions that adds value to people&apos;s lives.</description><link>https://arunangshu.dev/</link><language>en-us</language><item><title>The Power of Object-Oriented Programming: Building Maintainable Code</title><link>https://arunangshu.dev/blog/posts/2023-07-12-the-power-of-object-oriented-programming-building-maintainable-code/</link><guid isPermaLink="true">https://arunangshu.dev/blog/posts/2023-07-12-the-power-of-object-oriented-programming-building-maintainable-code/</guid><description>Explore the challenges of poor code structuring and the solution it demands: Object-Oriented Programming (OOP). Discover how OOP enhances simplicity, modularity, extensibility, and maintainability, and learn about essential OOP concepts like encapsulation, abstraction, inheritance, and polymorphism.</description><pubDate>Wed, 12 Jul 2023 14:24:06 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Once upon a time, programming was a mystic art! An art that could only be performed by the ones well versed in the way of computers. But this image of programming has long been changed. There are many tutorials out there both in texts and videos that make this art much easier to learn. One can learn any language and build their applications. But is that all? Or is there more to this than meets the eye?&lt;/p&gt;
&lt;h2&gt;The Story&lt;/h2&gt;
&lt;p&gt;You can now get started with building your app in any language. You settle on Python as it is a beginner-friendly language. You &lt;em&gt;google&lt;/em&gt; “Python tutorial” select one of the top results and start learning the language. You are now ready and one step closer to building your app. During this journey, many errors are going to attack and prevent you from completing the app, but your &lt;em&gt;Google-Fu&lt;/em&gt; is top-notch. Those puny errors will be of no match to you! After all the think, write, and debug cycles you have reached your goal. That app you wanted to build is now ready!&lt;/p&gt;
&lt;p&gt;Now happy and excited, you show off your learnings to your peers. You get compliments and also some interesting feedbacks for additional features. Inspired by the well build apps from big companies such as Microsoft, Google and Adobe, you decide to improve your app. You get to work and start writing code to add all those cool features your friends suggested. But wait! Now you are facing a different kind of problem. Your codebase is now a whopping 200 lines long, and now you’re finding it difficult to add new code. The errors are now much more frequent with functionalities breaking on adding new code. Being frustrated, you decide to take a few days of break.&lt;/p&gt;
&lt;p&gt;Now with a fresh spirit and mind, you decide to complete your app. You start scanning through your code to reach the point where you left off. But to your horror, you are now facing difficulties understanding your own code. Still undeterred, you push yourself for a couple of hours. To your dismay, you are still facing the same trouble as before. You lose all your motivation and finally decide to quit.&lt;/p&gt;
&lt;p&gt;So what happened? What went wrong?&lt;/p&gt;
&lt;h2&gt;The Analysis&lt;/h2&gt;
&lt;p&gt;What you are experiencing is a classic problem of &lt;em&gt;poor code structuring.&lt;/em&gt; This leads to low maintainability and makes it very hard to add new code. This is common in many beginner’s projects where the main focus is on functionality. So how do we write code which is not only functional but also easily maintainable and extendable?&lt;/p&gt;
&lt;h2&gt;The Solution&lt;/h2&gt;
&lt;p&gt;The term “&lt;strong&gt;Object-Oriented Programming (OOP)&lt;/strong&gt;” was coined by Alan Kay at grad school in 1966 or 1967. It took off in the software industry, replacing the largely prevalent procedural programming paradigm.&lt;/p&gt;
&lt;p&gt;The advantages of using this new paradigm are,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It improves &lt;strong&gt;simplicity&lt;/strong&gt;, as the software objects are analogous to the real-world objects. It brings down the program’s complexity by providing an intuitive idea about the structure.&lt;/li&gt;
&lt;li&gt;It encourages &lt;strong&gt;modularity&lt;/strong&gt;, as each object is a separate entity that is decoupled from each other.&lt;/li&gt;
&lt;li&gt;It improves &lt;strong&gt;extensibility&lt;/strong&gt;, as OOP has the concept of &lt;em&gt;classes&lt;/em&gt; and &lt;em&gt;inheritance&lt;/em&gt; where a class can extend upon the functionality of another class.&lt;/li&gt;
&lt;li&gt;It increases &lt;strong&gt;modifiability&lt;/strong&gt;, as we can change the internal implementation of class methods which would not affect other classes provided we don’t change the public interface. The internal implementations of objects are abstracted away from each other.&lt;/li&gt;
&lt;li&gt;It improves &lt;strong&gt;maintainability&lt;/strong&gt;, as classes are self-contained they can be maintained separately. This makes locating and fixing errors easier.&lt;/li&gt;
&lt;li&gt;It encourages &lt;strong&gt;reusability&lt;/strong&gt;, as we can instantiate a class anywhere and any number of times.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So following the OOP paradigm, we can easily resolve our code extensibility and maintainability issues. But hold on! how do we learn about it?&lt;/p&gt;
&lt;h2&gt;The Path&lt;/h2&gt;
&lt;p&gt;The OOP paradigm is a vast field with many programming languages that have slightly different implementations of it. But there are some core concepts that one needs to learn first to grasp it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Encapsulation&lt;/li&gt;
&lt;li&gt;Abstraction&lt;/li&gt;
&lt;li&gt;Inheritance&lt;/li&gt;
&lt;li&gt;Polymorphism&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I believe in the philosophy of &lt;em&gt;Learn by Doing&lt;/em&gt;, where you learn about something by getting hands-on with it. I have recently completed some exercises at &lt;a href=&quot;https://crio.do/&quot;&gt;Crio.Do&lt;/a&gt; on the said concepts. Solving a real-world based problem using the learned concepts goes a long way by solidifying the intuition and the concept together.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;At the beginning of every programmer’s life, their first major project is a structural mess. Learning the basic &lt;strong&gt;OOPS&lt;/strong&gt; concepts helps to introduce a structure to the code. But this is just the beginning of the journey. There are more stuff to learn like &lt;strong&gt;SOLID&lt;/strong&gt; and &lt;strong&gt;GRASP&lt;/strong&gt; principles and so on. This journey is a continuous evolution and has no real end. As the applications scale and the requirements change, there might arise a need for a new structure in the future. So staying updated is a crucial job for a developer in this ever-changing field of IT.&lt;/p&gt;
&lt;p&gt;So good luck with your journey! And thanks for taking the time to read my article.&lt;/p&gt;</content:encoded></item><item><title>Protohackers - 0: Smoke Test</title><link>https://arunangshu.dev/blog/posts/2023-07-17-protohackers-0-smoke-test/</link><guid isPermaLink="true">https://arunangshu.dev/blog/posts/2023-07-17-protohackers-0-smoke-test/</guid><description>Protohacker solution breakdown for the first problem.</description><pubDate>Mon, 17 Jul 2023 14:48:31 GMT</pubDate><content:encoded>&lt;h2&gt;P﻿roblem summary&lt;/h2&gt;
&lt;p&gt;The task is to create a generic server that implements the TCP Echo Service from RFC 862. The server should accept TCP connections and be capable of handling at least five simultaneous clients. Its main functionality is to receive data from clients and send it back unmodified. The server must handle binary data without altering it. Once a client finishes sending data and closes it’s sending side, the server should close the corresponding socket after receiving and echoing all the data. This behavior aligns with the requirements specified in the TCP Echo Service definition.&lt;/p&gt;
&lt;p&gt;P﻿roblem statement link: &lt;a href=&quot;https://protohackers.com/problem/0&quot;&gt;https://protohackers.com/problem/0&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Code&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;package&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;fmt&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;io&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;log&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;net&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;var&lt;/span&gt;&lt;span&gt; PORT &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;80&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;RunServer&lt;/span&gt;&lt;span&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;// Listen for incoming connections&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Listening on port &quot;&lt;/span&gt;&lt;span&gt;, PORT, &lt;/span&gt;&lt;span&gt;&quot; for incoming connections.&quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        lst, err &lt;/span&gt;&lt;span&gt;:=&lt;/span&gt;&lt;span&gt; net.&lt;/span&gt;&lt;span&gt;Listen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;tcp&quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&quot;:&quot;&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt;fmt.&lt;/span&gt;&lt;span&gt;Sprint&lt;/span&gt;&lt;span&gt;(PORT))&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; err &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;nil&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            &lt;/span&gt;&lt;span&gt;// Handle error&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            log.&lt;/span&gt;&lt;span&gt;Fatal&lt;/span&gt;&lt;span&gt;(err)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;// Echo all incoming data.&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            &lt;/span&gt;&lt;span&gt;// Accept a TCP connection&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            conn, err &lt;/span&gt;&lt;span&gt;:=&lt;/span&gt;&lt;span&gt; lst.&lt;/span&gt;&lt;span&gt;Accept&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; err &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;nil&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;                &lt;/span&gt;&lt;span&gt;// Handle error&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;                log.&lt;/span&gt;&lt;span&gt;Fatal&lt;/span&gt;&lt;span&gt;(err)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Accepted connection from &quot;&lt;/span&gt;&lt;span&gt;, conn.&lt;/span&gt;&lt;span&gt;RemoteAddr&lt;/span&gt;&lt;span&gt;().&lt;/span&gt;&lt;span&gt;String&lt;/span&gt;&lt;span&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;            &lt;/span&gt;&lt;span&gt;go&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;handleConnection&lt;/span&gt;&lt;span&gt;(conn)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;handleConnection&lt;/span&gt;&lt;span&gt;(c net.Conn) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;defer&lt;/span&gt;&lt;span&gt; c.&lt;/span&gt;&lt;span&gt;Close&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    io.&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(c, c)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Closing connection to &quot;&lt;/span&gt;&lt;span&gt;, c.&lt;/span&gt;&lt;span&gt;RemoteAddr&lt;/span&gt;&lt;span&gt;().&lt;/span&gt;&lt;span&gt;String&lt;/span&gt;&lt;span&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;span&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;RunServer&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;B﻿reakdown&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;package&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;import&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;fmt&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;io&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;log&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;span&gt;net&lt;/span&gt;&lt;span&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This section specifies that the code is part of the &lt;code&gt;main&lt;/code&gt; package, which is the default package for an executable Go program. Several libraries are then imported:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fmt&lt;/code&gt;: This package contains functions for formatted I/O.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;io&lt;/code&gt;: This package provides basic interfaces to I/O primitives.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;log&lt;/code&gt;: This package provides simple logging services.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;net&lt;/code&gt;: This package provides a portable interface for network I/O, including TCP/IP, UDP, and Unix domain sockets.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;var&lt;/span&gt;&lt;span&gt; PORT &lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;80&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here a global variable &lt;code&gt;PORT&lt;/code&gt; is declared and initialized to &lt;code&gt;80&lt;/code&gt;. This is the port that the server will listen on for incoming connections.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;RunServer&lt;/span&gt;&lt;span&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;	&lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Listening on port &quot;&lt;/span&gt;&lt;span&gt;, PORT, &lt;/span&gt;&lt;span&gt;&quot; for incoming connections.&quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		lst, err &lt;/span&gt;&lt;span&gt;:=&lt;/span&gt;&lt;span&gt; net.&lt;/span&gt;&lt;span&gt;Listen&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;tcp&quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;&quot;:&quot;&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span&gt;fmt.&lt;/span&gt;&lt;span&gt;Sprint&lt;/span&gt;&lt;span&gt;(PORT))&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		&lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; err &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;nil&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			log.&lt;/span&gt;&lt;span&gt;Fatal&lt;/span&gt;&lt;span&gt;(err)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		&lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			conn, err &lt;/span&gt;&lt;span&gt;:=&lt;/span&gt;&lt;span&gt; lst.&lt;/span&gt;&lt;span&gt;Accept&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			&lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; err &lt;/span&gt;&lt;span&gt;!=&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;nil&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;				log.&lt;/span&gt;&lt;span&gt;Fatal&lt;/span&gt;&lt;span&gt;(err)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Accepted connection from &quot;&lt;/span&gt;&lt;span&gt;, conn.&lt;/span&gt;&lt;span&gt;RemoteAddr&lt;/span&gt;&lt;span&gt;().&lt;/span&gt;&lt;span&gt;String&lt;/span&gt;&lt;span&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;			&lt;/span&gt;&lt;span&gt;go&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;handleConnection&lt;/span&gt;&lt;span&gt;(conn)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;		}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;RunServer&lt;/code&gt; function starts an infinite loop that listens for incoming connections on the specified port. If it encounters an error, it logs the error and terminates the program. If it successfully accepts a connection, it prints a log message stating that it has accepted the connection from the remote address, and calls the &lt;code&gt;handleConnection&lt;/code&gt; function in a separate goroutine, passing the connection to it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;handleConnection&lt;/span&gt;&lt;span&gt;(c net.Conn) {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;	&lt;/span&gt;&lt;span&gt;defer&lt;/span&gt;&lt;span&gt; c.&lt;/span&gt;&lt;span&gt;Close&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;	io.&lt;/span&gt;&lt;span&gt;Copy&lt;/span&gt;&lt;span&gt;(c, c)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;	log.&lt;/span&gt;&lt;span&gt;Print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&quot;Closing connection to &quot;&lt;/span&gt;&lt;span&gt;, c.&lt;/span&gt;&lt;span&gt;RemoteAddr&lt;/span&gt;&lt;span&gt;().&lt;/span&gt;&lt;span&gt;String&lt;/span&gt;&lt;span&gt;())&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This function is used to handle a new connection. It uses the &lt;code&gt;defer&lt;/code&gt; statement to ensure that the connection will be closed when the function exits, regardless of how it exits. It then copies data from the connection to itself, effectively echoing all incoming data back to the client. Once the connection is closed, a log message is printed to indicate this.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/strong&gt; &lt;code&gt;io.Copy(c, c)&lt;/code&gt; is a simple echo operation. It copies data from the source (the connection itself) to the destination (again, the connection itself). So, whatever data the server receives from a client, it sends the same data back to the client.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code&gt;&lt;span&gt;&lt;span&gt;func&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;span&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;    &lt;/span&gt;&lt;span&gt;RunServer&lt;/span&gt;&lt;span&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;main&lt;/code&gt; function is the entry point for the executable program. It simply calls the &lt;code&gt;RunServer&lt;/code&gt; function to start the server. The server will then listen indefinitely for incoming connections on the specified port.&lt;/p&gt;</content:encoded></item></channel></rss>