<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by AdityaSinghVats on Medium]]></title>
        <description><![CDATA[Stories by AdityaSinghVats on Medium]]></description>
        <link>https://medium.com/@adityakumarbgs6?source=rss-4979476224ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*V_mIr1boxhsj-cbk</url>
            <title>Stories by AdityaSinghVats on Medium</title>
            <link>https://medium.com/@adityakumarbgs6?source=rss-4979476224ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:43:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adityakumarbgs6/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Network Programming Part 2 — TCP & UDP]]></title>
            <link>https://medium.com/@adityakumarbgs6/network-programming-part-2-tcp-udp-3fbe152171c2?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fbe152171c2</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[cplusplus]]></category>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[low-level-programming]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 17:32:10 GMT</pubDate>
            <atom:updated>2025-04-03T17:10:29.884Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*1tuET3seSaipXIDZ3_Qm8Q.png" /></figure><h3>Network Programming using WinSock Part 2 — TCP &amp; UDP</h3><p>Let’s continue our journey of learning about socket programming , in this second part we will be exploring TCP and UDP. In the first part we were able to setup a connection between server and client, now in this blog we will be trying to send some data over this connection.</p><h3>1. Introduction to TCP</h3><p>TCP is unique in its implementation as it requires a stable connection via a socket between machines before sending any data, which is different from UDP.</p><ul><li>For sending data we need to use <strong>send( )</strong> function.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gyZBiQOEEV8BAtqNfkqu7Q.png" /></figure><ul><li>SOCKET s is returned by the <strong>accept( )</strong> function of the server. Pointer to a char array called buf will contain our data.</li><li><strong>send( ) </strong>function can be used both ways i.e. server to client as well as client to server. We want a non-zero value as the return value to make sure our data was sent.</li><li>Example :-</li></ul><pre>char buffer[200];<br>printf(&quot;Enter your message&quot;);<br>cin.getline(buffer, 200);<br>//socket , pointer to data array, size/length, no flag <br>int byteCount = send(clientSocket, buffer, 200, 0);<br>if(byteCount == SOCKET_ERROR){<br>     printf(&quot;Server send error %ld.\n&quot;, WSAGetLastError());  <br>     return -1;<br>}else{//%ld -&gt; long decimal<br>     printf(&quot;Server: sent %ld bytes \n&quot;, byteCount);<br>}</pre><ul><li>If client is starting the conversation, server need to receive the data using <strong>recv( ) </strong>function. We need to make sure if client is sending data , then server is only receiving and vice versa , otherwise these blocking functions will cause problems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XdyTdTMVKPAHpLld30W9XQ.png" /></figure><ul><li>Example :- We need to create a buffer of same size on server side for receiving data.</li></ul><pre>char receiveBuffer[200] = &quot;&quot;;<br>int byteCount = recv(acceptSocket, receiveBuffer, 200, 0);<br>if(byteCount &lt; 0){<br>     printf(&quot;Client error %ld.\n&quot;, WSAGetLastError());  <br>     return 0;<br>}else{// %s -&gt; display string i.e. actual data<br>     printf(&quot;Received data: %s \n&quot;, receiveBuffer);<br>}</pre><h4>Transmitting Objects</h4><p>To transmit object of different user defined data types, we can cast the reference of the object into a <strong>char *</strong> and <strong>sizeof ( )</strong> of data , then simply use our <strong>send( )</strong> and <strong>recv( )</strong> functions . <strong>sizeof( )</strong> will help make a data member to hold the data of required size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S9-d5BLJYaMVVigFisI_Iw.png" /></figure><h4>String functions to work with send and recv</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxaUNhDnUrM0aKImZocxrQ.png" /></figure><ul><li><strong>strcmp( )</strong> compares characters on basis of their ASCII values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihHMm3AWA-ZDI4Rt2kEmow.png" /></figure><ul><li>Example</li></ul><pre>#include&lt;bits/stdc++.h&gt;<br>using namespace std;<br>int main(){<br>    char name[] = &quot;ADITYA&quot;;<br>    cout&lt;&lt;strcmp(name, &quot;ADITYA&quot;)&lt;&lt;&quot;\n&quot;;<br>    cout&lt;&lt;strcmp(name, &quot;AARAV&quot;)&lt;&lt;&quot;\n&quot;;<br>    cout&lt;&lt;strcmp(name, &quot;SINGHVATS&quot;)&lt;&lt;&quot;\n&quot;;<br>    return 0;<br>}<br>//OUTPUT<br>0<br>1<br>-1</pre><h3>2. Introduction to UDP</h3><h4>Features of UDP :-</h4><ul><li>Universal datagram protocol.</li><li>Client and server don’t maintain a constant connection.</li><li>Either can transmit a data packet.</li><li>The receiving application can determine who sent the package and respond if necessary.</li><li>There is however no guarantee that the packet will reach its destination.</li><li>Reduces the lag associated with TCP.</li><li>Used in multiplayer games where transmitted data is not critical.</li></ul><h4>Setup</h4><ul><li>Initialise the library as with TCP.</li><li>Create a socket configured for TCP.</li><li>For server only to bind the socket to an address.</li><li>Invoke <strong>sendto </strong>to transmit data, different from TCP.</li><li>Invoke <strong>recvfrom </strong>to receive data, different from TCP.</li></ul><p>We won’t use <strong>listen( )</strong> and <strong>accept( ) , connect( ) </strong>for connecting using UDP protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uE--tAcCNECmLHOMux3mdQ.png" /></figure><ul><li>For sending data we need to use <strong>sendto( ) </strong>function.</li><li>We skip all step required to listen for request and then confirm connection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_paSQ3Fr1dPLYxW-BqZyQ.png" /></figure><pre>    sockaddr_in address;<br>    address.sin_family = AF_INET;<br>    InetPton(AF_INET, _T(&quot;127.0.0.1&quot;), &amp;address.sin_addr.s_addr);<br>    address.sin_port = htons(5555);<br>    char buffer[200] = &quot;send to server&quot;;<br>    int byteSent = sendto(socket, (const char*)buffer, strlen(buffer), 0, (struct sockaddr*)&amp;address, sizeof(address));<br>    if(byteSent == -1){<br>        cout&lt;&lt;&quot;Error transmitting data&quot;&lt;&lt;endl;<br>        WSACleanup();<br>        return 0;<br>    }else{<br>        cout&lt;&lt;cout&lt;&lt;&quot;Data sent:&quot;&lt;&lt;buffer&lt;&lt;endl;<br>    }</pre><ul><li>Receiving data using <strong>recvfrom( ) .</strong></li></ul><pre>char buffer[200] = &quot;&quot;;<br>    sockaddr_in clientAddress;<br>    int clientAddress_len = (int)sizeof(clientAddress);<br>    int bytesReceived = recvfrom(socket, buffer, 200, 0, (struct sockaddr*)&amp;clientAddress, clientAddress_len);<br>    if(bytesReceived &lt; 0){<br>        cout&lt;&lt;&quot;Couldn&#39;t receive datagram.&quot;&lt;&lt;endl;<br>        WSACleanup();<br>        return 0;<br>    }</pre><h4>Transmitting Objects</h4><p>To transmit object of different user defined data types, here we have to explicity upcast and downcast the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qh2dcBVI_-qy3N0g_kpaQw.png" /></figure><ul><li>We will have to convert every data type into a char array using <strong>sprintf( )</strong> before sending it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UK7ErhEzEcusOrbxVR2uEg.png" /></figure><h4>Let’s Code It</h4><p>Now onto the exciting part , let’s add some code to our previous code base to be able to send data using TCP.</p><ul><li>Client Side Code</li></ul><pre>#include &lt;winsock2.h&gt;<br>#include &lt;ws2tcpip.h&gt;<br>#include &lt;iostream&gt;<br>#include &quot;stdafx.h&quot;<br><br>using namespace std;<br>int main() {<br>    //link the dll step 1<br>    WSADATA wsadata;<br>    int wsaerr;<br>    WORD wVersionRequested = MAKEWORD(2, 2);<br>    wsaerr = WSAStartup(wVersionRequested, &amp;wsadata);<br>    if (wsaerr != 0) {<br>        cout &lt;&lt; &quot;The winsock dll not found&quot; &lt;&lt; endl;<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;The winsock dll found&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Status: &quot; &lt;&lt; wsadata.szSystemStatus &lt;&lt; endl;<br>    }<br>    //step 2<br>    SOCKET clientsocket = INVALID_SOCKET;<br>    clientsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br><br>    if (clientsocket == INVALID_SOCKET) {<br>        cout &lt;&lt; &quot;Error at socket():&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;Socket is OK&quot; &lt;&lt; endl;<br>    }<br>    //step 3<br>    int port = 55555;<br>    sockaddr_in clientService;<br>    clientService.sin_family = AF_INET;<br>    InetPton(AF_INET, _T(&quot;127.0.0.1&quot;), &amp;clientService.sin_addr.s_addr);<br>    clientService.sin_port = htons(port);<br>    if (connect(clientsocket, (SOCKADDR*)&amp;clientService, sizeof(clientService)) == SOCKET_ERROR) {<br>        cout &lt;&lt; &quot;Client connect() failed:&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;Client connect(): is OK&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Client can start sending and receiving data...&quot; &lt;&lt; endl;<br>    }<br>    //step 4 send user data to server<br>    char buffer[200];<br>    cout &lt;&lt; &quot;Enter the message to send to server: &quot;;<br>    cin.getline(buffer, 200);<br>    int byteCount = send(clientsocket, buffer, 200, 0);<br>    if (byteCount &gt; 0) {<br>        cout &lt;&lt; &quot;Message Sent: &quot; &lt;&lt; buffer &lt;&lt; endl;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;Error sending message&quot; &lt;&lt; endl;<br>        WSACleanup();<br>    }<br>    //step 5 accept confirmation close the socket and clean resources<br>    byteCount = recv(clientsocket, buffer, 200, 0);<br>    if (byteCount &gt; 0) {<br>        cout &lt;&lt; &quot;Confirmation Message Received: &quot; &lt;&lt; buffer &lt;&lt; endl;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;Error sending message&quot; &lt;&lt; endl;<br>        WSACleanup();<br>    }<br>    system(&quot;pause&quot;);<br>    WSACleanup();<br>    cout &lt;&lt; &quot;Closed Socket&quot; &lt;&lt; endl;<br>    return 0;<br>}<br><br></pre><ul><li>Server Side Code</li></ul><pre>#include &lt;winsock2.h&gt;<br>#include &lt;ws2tcpip.h&gt;<br>#include &lt;iostream&gt;<br>#include &quot;stdafx.h&quot;<br><br><br>using namespace std;<br>int main() {<br><br>    //link the dll step 1<br>    WSADATA wsadata;<br>    int wsaerr;<br>    WORD wVersionRequested = MAKEWORD(2, 2);<br>    wsaerr = WSAStartup(wVersionRequested, &amp;wsadata);<br>    if (wsaerr != 0) {<br>        cout &lt;&lt; &quot;The winsock dll not found&quot; &lt;&lt; endl;<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;The winsock dll found&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Status: &quot; &lt;&lt; wsadata.szSystemStatus &lt;&lt; endl;<br>    }<br><br>    //socket creation step 2<br>    SOCKET serversocket = INVALID_SOCKET;<br>    serversocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br><br>    if (serversocket == INVALID_SOCKET) {<br>        cout &lt;&lt; &quot;Error at socket():&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;socket is OK&quot; &lt;&lt; endl;<br>    }<br>    //closesocket(serversocket);<br><br>    //bind step 3<br>    int port = 55555;<br>    sockaddr_in service;<br>    service.sin_family = AF_INET;<br>    InetPton(AF_INET, _T(&quot;127.0.0.1&quot;), &amp;service.sin_addr.s_addr);<br>    service.sin_port = htons(port);<br>    if (bind(serversocket, (SOCKADDR*)&amp;service, sizeof(service)) == SOCKET_ERROR) {<br>        cout &lt;&lt; &quot;bind() failed:&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        closesocket(serversocket);<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;bind() is OK&quot; &lt;&lt; endl;<br>    }<br><br>    //Listen on socket step 4<br>    if (listen(serversocket, 1) == SOCKET_ERROR) {<br>        cout &lt;&lt; &quot;listen() : error listening on socket&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>    }<br>    else cout &lt;&lt; &quot;Listen() is OK, I&#39;m waiting for connections...&quot; &lt;&lt; endl;<br><br>    //accept the connection step 5<br>    SOCKET acceptSocket;<br>    acceptSocket = accept(serversocket, nullptr, nullptr);<br>    if (acceptSocket == INVALID_SOCKET) {<br>        cout &lt;&lt; &quot;accept failed:&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return -1;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;accept() is working&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Client is connected&quot; &lt;&lt; endl;<br>    }<br>    //step 6 chat to client<br>    char buffer[200];<br>    int byteCount = recv(acceptSocket, buffer, 200, 0);<br>    if (byteCount &gt; 0) {<br>        cout &lt;&lt; &quot;Message received: &quot; &lt;&lt; buffer &lt;&lt; endl;<br>    }<br>    else WSACleanup();<br><br>    //step 7 send confirmation<br>    char confirmation[200] = &quot;Message Received&quot;;<br>    byteCount = send(acceptSocket, confirmation, 200, 0);<br>    if (byteCount &gt; 0) {<br>        cout &lt;&lt; &quot;Confirmation Message Sent: &quot; &lt;&lt; confirmation &lt;&lt; endl;<br>    }<br>    else WSACleanup();<br>    system(&quot;pause&quot;);<br>    WSACleanup();<br>    cout &lt;&lt; &quot;Closed Socket&quot; &lt;&lt; endl;<br>    return 0;<br>}</pre><h3>Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TTaNmwq5XeyJdF2B04lrAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJ17UpXgt_bbhGTDFiVsfQ.png" /></figure><p>Thank you reading up to this point , I hope you found this blog useful and interesting 😉😁😊.</p><p>This is the end of our 2 part series for learning about network programming using C++ and Windows.</p><p>Come back for more useful and interesting blogs . Follow me and be healthy 🙌, wealthy 💵and wise 🦉.</p><p>Feel free to contact me for any further questions.</p><p>Find the code repo here <a href="https://github.com/Adityasinghvats/Simple-WinSock-Server-Client">https://github.com/Adityasinghvats/Simple-WinSock-Server-Client</a></p><h3>Find me here :</h3><p><a href="https://aditya.webhop.me/">https://aditya.webhop.me</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fbe152171c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Programming Part 1 using Winsock — Programming Sockets]]></title>
            <link>https://medium.com/@adityakumarbgs6/network-programming-part-1-using-winsock-programming-sockets-1978e4de94a2?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1978e4de94a2</guid>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[cpp-programming]]></category>
            <category><![CDATA[udp-protocol]]></category>
            <category><![CDATA[winsock]]></category>
            <category><![CDATA[socket-programming]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 14:13:46 GMT</pubDate>
            <atom:updated>2025-03-31T19:09:55.372Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*VpioRKKEGSCFYKQsiugUvA.png" /></figure><h3>Network Programming Part 1 using Winsock — Programming Sockets</h3><p>Sockets were initially developed for UNIX systems . Later on windows implemented it and named it Winsock , which can be found under C:\Windows\System32 as ws2_32.dll. We will be learning about socket programming using a windows system.</p><ul><li>0SI — Open System Interconnection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0e-fLkBwDxU0pxswBeI5Gw.png" /></figure><ul><li>For this example , we need to use the physical layer of the OSI model.</li></ul><blockquote>We break down the data which we get from <strong><em>Application layer</em></strong> into small packets using serialization / deserialization using the capability of the <strong><em>Presentation layer,</em></strong> to be able to send it using socket connection, present in <strong><em>Session layer</em></strong> , these sockets use <strong>TCP /UDP protocol </strong>from the <strong><em>Transport layer</em></strong>. We will get a unique <strong>IP</strong> of our server and client from the <strong><em>Network layer</em></strong>. The <strong><em>Data Link layer</em></strong> is ethernet connection layer.</blockquote><h3>1. IP Addresses</h3><ul><li>The server is continually waiting for incoming connections. This is called<strong> listening</strong> which is always done on a certain IP and port number.</li><li>When developing Network programs the port number of the server is usually specified within the code , whereas the client port number is allocated of the OS. The loopback address 127.0.0.1 refers to the current machine, this can be used during development to test both client and server on a single machine.</li></ul><h3>2. Ports</h3><ul><li>After getting IP addresses client and server need to decide on a port to be able to share data, the client needs to know the port of server and the server needs to know the port of the client. Each machine has almost<strong> 65000</strong> ports , a <strong>16 bit</strong> address.</li></ul><h3>3. Socket</h3><ul><li>Think of it as a pipeline between 2 ports, which allows data flow. They are 2 — way send and receive the data.</li></ul><blockquote>There are 2 different types :-</blockquote><blockquote>Streaming Socket ( TCP )</blockquote><blockquote>Datagram Socket ( UDP )</blockquote><ul><li>When server creates a socket , it is yet to be bound to a IP and port number .</li><li>Next up we bind it to a valid <strong>IP</strong> and <strong>Port Number</strong></li><li>Now the socket is put in L<strong>istening</strong> mode.</li><li>Now on receiving a request from the client , the server makes a copy of the its port and allow the connection ( <em>P.S : — port of client and server are mostly different</em> ), status now is <strong>connected</strong> . The original port is still open and listening for connections.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bnDFzgCVC-N_VaprM_q6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nff1MZQjD_3lk77J3GBLVQ.png" /></figure><ul><li>For creating socket programs , first we need to get the basics out of our way.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHB5LSe6o30W2eMURiFS7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eo4FJAjX50PHf84l6QMMYg.png" /></figure><h3>Coding Implementation</h3><ul><li>Create 2 visual studio solutions, one named server and another named client, go to the project properties and inside the Linker &gt; additional dependencies &gt; edit add win2_32.lib .</li><li>Make sure to add a header file stdafx.h to both the solutions in Visual studio inside Header files .</li></ul><pre>// stdafx.h : include file for standard system include files,<br>// or project specific include files that are used frequently, but<br>// are changed infrequently<br>//<br><br>#pragma once<br><br>// General includes<br>#include &lt;windows.h&gt;<br>#include &lt;winbase.h&gt;<br><br>// _ASSERTE declaration (used by ATL) and other macros<br>//#include &quot;macros.h&quot;<br><br>#include &lt;iostream&gt;<br>#include &lt;tchar.h&gt;<br>#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS  <br><br>// ATL includes<br>#pragma warning( disable: 4189 )    // disable local variable is initialized but not referenced<br>#include &lt;atlbase.h&gt;<br><br>// STL includes<br>#include &lt;vector&gt;<br>#include &lt;map&gt;<br>#include &lt;algorithm&gt;<br>#include &lt;string&gt;<br>#include &lt;fstream&gt;<br>using namespace std;<br><br>// Used for safe string manipulation<br>#include &lt;strsafe.h&gt;<br><br>//#include &quot;shadow.h&quot;<br>#pragma once</pre><p><strong>Step 1. Linking DLL and checking.</strong></p><pre>#include&lt;winsock2.h&gt;<br>#include&lt;iostream&gt;<br>using namespace std;<br>int main(){<br>    WSADATA wsadata;<br>    int wsaerr;<br>    WORD wVersionRequested = MAKEWORD(2, 2);<br>    wsaerr = WSAStartup(wVersionRequested, &amp;wsadata);<br>    if(wsaerr != 0){<br>        cout&lt;&lt;&quot;The winsock dll not found&quot;&lt;&lt;endl;<br>        return 0;<br>    }else{<br>        cout&lt;&lt;&quot;The winsock dll found&quot;&lt;&lt;endl;<br>        cout&lt;&lt;&quot;Status: &quot;&lt;&lt;wsadata.szSystemStatus&lt;&lt;endl;<br>    }<br>    WSACleanup();<br>    return 0;<br>}</pre><p><strong>Step 2. Create socket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBMC9IWBkzTvG_iAW3LoTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MOqrHvEDH5rMrLbjEtqQng.png" /></figure><pre>SOCKET serversocket = INVALID_SOCKET;<br>    serversocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br><br>    if(serversocket == INVALID_SOCKET){<br>        cout&lt;&lt;&quot;Error at socket():&quot;&lt;&lt;WSAGetLastError()&lt;&lt;endl;<br>        WSACleanup();<br>        return 0;<br>    }else{<br>        cout&lt;&lt;&quot;socket is OK&quot;&lt;&lt;endl;<br>    }<br>//closesocket(serversocket);</pre><p><strong>Step 3. Bind the socket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*keTYEHgo5vA5xViAcECmjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GapjQH2Rp4tn2nI74D4wfg.png" /></figure><blockquote>htons converts little endian value data to network byte order which is in big endian. Big endian is CPU in which MSB is stored at lowest memory address.</blockquote><pre>int port = 55555;<br>sockaddr_in service;<br>service.sin_family = AF_INET;<br>InetPton(AF_INET, _T(&quot;127.0.0.1&quot;), &amp;service.sin_addr.s_addr);<br>service.sin_port = htons(port);<br>if (bind(serversocket, (SOCKADDR*)&amp;service, sizeof(service)) == SOCKET_ERROR) {<br>    cout &lt;&lt; &quot;bind() failed:&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>    closesocket(serversocket);<br>    WSACleanup();<br>    return 0;<br>}<br>else {<br>    cout &lt;&lt; &quot;bind() is OK&quot; &lt;&lt; endl;<br>}</pre><p><strong>Step 4. Listen on port</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zYZUou2KJEDxJM-B2ENcoQ.png" /></figure><pre>if(listen(serversocket, 1) == SOCKET_ERROR){<br>        cout&lt;&lt;&quot;listen() : error listening on socket&quot;&lt;&lt;WSAGetLastError()&lt;&lt;endl;<br>    }else cout&lt;&lt;&quot;Listen() is OK, I&#39;m waiting for connctions...&quot;&lt;&lt;endl;</pre><p><strong>Step 5. Accept function</strong></p><ul><li>It is a blocking function and it will stop the server and wait until the client has established a connection with the socket , accept the connection and move on .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Hg-Vqh840lxfmGmQymFBA.png" /></figure><ul><li>This function call will work to create a fork of our server socket connect it with the client and the original server socket is now free for new connections. It returns a value of type socket .</li></ul><pre>SOCKET acceptSocket;<br>    acceptSocket = accept(serversocket, NULL, NULL);<br>    if(acceptSocket == INVALID_SOCKET){<br>        cout&lt;&lt;&quot;accept failed:&quot;&lt;&lt;WSAGetLastError()&lt;&lt;endl;<br>        WSACleanup();<br>        return -1;<br>    }else cout&lt;&lt;&quot;accept() is working&quot;&lt;&lt;endl;</pre><ul><li>The setup for server is finished.</li><li>Now we will create the client.</li></ul><h3>Client Side</h3><ul><li>Client side <strong>socket( )</strong> &amp; <strong>connect( )</strong> function will automatically bind the socket and IP provided.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMQeLnKfsOmuTon-kTpqJg.png" /></figure><pre>#include &lt;winsock2.h&gt;<br>#include &lt;ws2tcpip.h&gt;<br>#include &lt;iostream&gt;<br>#include &quot;stdafx.h&quot;<br><br>using namespace std;<br>int main() {<br>    //link the dll <br>    WSADATA wsadata;<br>    int wsaerr;<br>    WORD wVersionRequested = MAKEWORD(2, 2);<br>    wsaerr = WSAStartup(wVersionRequested, &amp;wsadata);<br>    if (wsaerr != 0) {<br>        cout &lt;&lt; &quot;The winsock dll not found&quot; &lt;&lt; endl;<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;The winsock dll found&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Status: &quot; &lt;&lt; wsadata.szSystemStatus &lt;&lt; endl;<br>    }<br><br>    SOCKET clientsocket = INVALID_SOCKET;<br>    clientsocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br><br>    if (clientsocket == INVALID_SOCKET) {<br>        cout &lt;&lt; &quot;Error at socket():&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;socket is OK&quot; &lt;&lt; endl;<br>    }<br><br>    int port = 55555;<br>    sockaddr_in clientService;<br>    clientService.sin_family = AF_INET;<br>    InetPton(AF_INET, _T(&quot;127.0.0.1&quot;), &amp;clientService.sin_addr.s_addr);<br>    clientService.sin_port = htons(port);<br>    if (connect(clientsocket, (SOCKADDR*)&amp;clientService, sizeof(clientService)) == SOCKET_ERROR) {<br>        cout &lt;&lt; &quot;client connect() failed:&quot; &lt;&lt; WSAGetLastError() &lt;&lt; endl;<br>        WSACleanup();<br>        return 0;<br>    }<br>    else {<br>        cout &lt;&lt; &quot;client connect(): is OK&quot; &lt;&lt; endl;<br>        cout &lt;&lt; &quot;Client can start sending and receiving data...&quot; &lt;&lt; endl;<br>    }<br>    system(&quot;pause&quot;);<br>    WSACleanup();<br>    return 0;<br>}</pre><ul><li>Now, open both the solutions side by side and run the server.cpp first solution and then the client.cpp solution.</li><li>Serve side shell.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yHZR8_kTOLdmuzDtp2LmhQ.png" /></figure><ul><li>Client Side Shell.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QX_W5A-t5810F6f3FOR0aA.png" /></figure><p>Thank you reading up to this point , I hope you found this blog useful and interesting 😉😁😊.</p><p>Come back for more useful and interesting blogs . Follow me and be healthy 🙌, wealthy 💵and wise 🦉.</p><p>In the P<strong>art 2</strong> , we will be using <strong>TCP</strong> and <strong>UDP</strong> connection to create a socket to transfer data.</p><p>Feel free to contact me for any further questions.</p><h3>Find me here :</h3><p><a href="https://adityasinghvats.github.io/adix/">https://ad</a>itya.webhop.me</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1978e4de94a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a basic Mobile Game with Raymob and C++]]></title>
            <link>https://medium.com/@adityakumarbgs6/build-a-basic-mobile-game-with-raymob-and-c-ed22047f0f5d?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed22047f0f5d</guid>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[raylib]]></category>
            <category><![CDATA[cpp-programming]]></category>
            <category><![CDATA[raymob]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Sat, 08 Mar 2025 15:58:41 GMT</pubDate>
            <atom:updated>2025-03-08T15:58:41.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*gAAyVLhIfF3PvmGZXduAOQ.png" /></figure><p>You might have built mobile games with Unity, Unreal Engine, Pygame, Godot Engine. But , today we will be building a mobile game with Raymob , which is a open source framework built on top of Raylib using JNI and NDK to access Android specific features like touch screen, haptic motor, soft keyboard, etc.</p><p>Check out the video : <a href="https://youtu.be/ckeR_KAiF9A">https://youtu.be/ckeR_KAiF9A</a></p><h3>1. Prerequisites</h3><ul><li>Android Studio setup with full SDK setup , adb tools , emulator, environment variables should be properly setup.</li><li>Now go to the SDK Manager and tick NDK , CMake and click apply and download dependencies for NDK development.</li><li>It should look something like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rZxut86thATZWiA3Bt-lQ.png" /></figure><ul><li>Now close Android Studio and re launch it , you are ready to roll.</li></ul><h3>2. Project Setup</h3><ul><li>Go to the Github repo :- <a href="https://github.com/Bigfoot71/raymob">Bigfoot71/raymob: Simple raylib implementation for Android</a> and download the zip file onto your computer.</li><li>Unzip the file named raymob-master and open Android Studio and open project and choose the file you unzipped and let the gradle sync continue.</li><li>Now you will find a sample code app/src/cpp/main.c , but we will be building our own game of a bouncing ball.</li><li>Up next you need to create 3 files main.cpp , ball.h , ball.cpp inside the app/src/cpp .</li><li>Now open main.cpp and write the following code.</li></ul><pre>#include &lt;raymob.h&gt;<br>#include &quot;ball.h&quot;<br><br>int main()<br>{<br>    const Color darkGreen = {20, 160, 133, 255};<br><br>    Ball ball;<br><br>    //if needed we can get width and height of screen using GetScreenWidth() and GetScreenHeight()<br>    //using 0, 0 for full screen view<br>    InitWindow(0, 0, &quot;Raymob Demo&quot;);<br>    //fix the frame rate to 60<br>    SetTargetFPS(60);<br><br>   //until window is not closed<br>    while (!WindowShouldClose())<br>    {<br>        //look for key press event to end game loop<br>        if(IsKeyPressed(KEY_BACK) || IsGestureDetected()){<br>            ball.running = false;<br>        }<br><br>        if(ball.running){<br>            ball.Update();<br>        }else{<br>            CloseWindow();<br>        }<br>        BeginDrawing();<br>        ClearBackground(darkGreen);<br>        ball.Draw();<br>        EndDrawing();<br>    }<br><br>    CloseWindow();<br>}</pre><ul><li>Now , open ball.h which a header file for our game logic, header files are used in CPP to promote code modularity.</li></ul><pre>#pragma once<br><br>class Ball{<br>public:<br>    Ball(); //default constructor<br>    void Update(); //game update method<br>    void Draw() const;<br>    bool running; //running variable which will be made false to end game loop.<br><br>private:<br>    int x;<br>    int y;<br>    int speedX;<br>    int speedY;<br>    int radius;<br>};<br>//<br>// Created by aditya on 04-03-2025.<br>//</pre><ul><li>Now inside the ball.cpp we will implement all the methods and give values to all parameters of the constructor. It will look something like this.</li></ul><pre>#include &quot;ball.h&quot;<br>#include &lt;raylib.h&gt;<br><br>//here we are initialising the default constructor of Ball class by using scope resolution operator<br>Ball::Ball(): x(100), y(100), speedX(5), speedY(5), radius(15), running(true){}<br><br>void Ball::Update()<br>{<br>    x += speedX;<br>    y += speedY;<br><br>    const int screenWidth = GetScreenWidth();//built in function<br>    const int screenHeight = GetScreenHeight();<br><br>    //when the ball reaches a corner<br>    if ((x + radius &gt;= screenWidth) || (x - radius &lt;= 0)) {<br>        speedX *= -1;<br>    }<br><br>    if ((y + radius &gt;= screenHeight) || (y - radius &lt;= 0)) {<br>        speedY *= -1;<br>    }<br>}<br><br>void Ball::Draw() const<br>{<br>    DrawCircle(x, y, radius, WHITE);<br>}</pre><p>Now you are ready to run the game and you will see a bouncing ball animation.</p><p>Connect a physical Android device or your emulator setup.</p><p>Click run app and you will see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7vNhSmXXvsJj99_HAJHxQ.png" /></figure><p>This is a very basic example of what you can with the library, you can now try to make a Mobile version of your favourite Raylib game .</p><p>If you want reference for making a Raylib game check out this repo : <a href="https://github.com/Adityasinghvats/Retro-Snake">Adityasinghvats/Retro-Snake: A retro-snake game built using Raylib and C++</a></p><p><strong>Congratulations</strong> on building your first mobile simulation using C++.</p><p>Come back for more useful and interesting blogs . Follow me and be healthy, wealthy and wise.</p><h3>Find me here :</h3><p><a href="https://adityasinghvats.github.io/adix/">https://adityasinghvats.github.io/adix/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed22047f0f5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build your web server in C++ with Crow.]]></title>
            <link>https://medium.com/@adityakumarbgs6/build-your-web-server-in-c-with-crow-26ce0a2322af?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/26ce0a2322af</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[crow-web-server]]></category>
            <category><![CDATA[cplusplus]]></category>
            <category><![CDATA[vcpkg]]></category>
            <category><![CDATA[visual-studio]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Fri, 07 Feb 2025 14:03:10 GMT</pubDate>
            <atom:updated>2025-02-07T14:03:10.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9s480Wv9CJYL80Etf1ENfw.jpeg" /></figure><p>Great you are back, I just want to ask you something ? Have you ever created a web server using a microframework before like flask or express and served a simple webpage and tried out some query parameters in the URL.</p><p>So, why not put your C++ skills to good use and build an simple web server in C++. This blog is specifically targeted towards windows users, others can refer the docs for installation.</p><p>First and foremost , we should get ready with our tools:-</p><ol><li>Visual Studio -An IDE for windows application development by Microsoft. Keep in mind to include packages for C++ development during installation.</li><li>vcpkg - Package manager for C++ just like npm or pip.</li></ol><h3>Now Let’s begin with installing crow as a package.</h3><pre>vcpkg install crow</pre><p>Next up we will link vcpkg globally so that we don’t have to bother with CMake, first and foremost get into to root directory of where vcpkg was installed. For me it was C:\Users\aditya\vcpkg .</p><pre>cd &lt;Your file path to vcpkg&gt;</pre><p>Now to link all the installations , run the command.</p><pre>vcpkg integrate install</pre><p>What this command does?</p><ul><li><strong>Modifies Visual Studio’s MSBuild Targets:</strong> It modifies the MSBuild targets files that Visual Studio uses to build projects. This modification tells Visual Studio to search for include directories and library paths within your vcpkg installation directory when building any C++ project.</li><li><strong>Automatic Package Linking:</strong> After running this command, when you build a Visual Studio project that requires a vcpkg package, Visual Studio will automatically:</li><li><strong>Find the header files</strong> in the vcpkg/installed/&lt;triplet&gt;/include directory.</li><li><strong>Find the library files (.lib, .dll)</strong> in the vcpkg/installed/&lt;triplet&gt;/lib and vcpkg/installed/&lt;triplet&gt;/bin directories.</li><li><strong>Link the necessary libraries</strong> during the linking stage of your build process.</li></ul><h3>Now we are ready to build our project</h3><ol><li>Open visual studio and create a new empty project , name your project as per your wish and leave all the rest as default.</li><li>Open solution explorer on your right hand side and right click on Source Files &gt; add &gt; new item &gt; main.cpp and add.</li><li>Inside that file you can copy the following code to setup a basic server with 3 different routes and 3 different basic features of crow.</li></ol><pre>#include &lt;crow.h&gt;<br><br>int main() {<br> crow::SimpleApp app;<br>    CROW_ROUTE(app, &quot;/&quot;)([]() {<br>        std::string res =  &quot;Crow server is running &quot;;<br>        return res;<br>    });<br>    CROW_ROUTE(app, &quot;/&lt;string&gt;&quot;)([](std::string name) {<br>        auto page = crow::mustache::load(&quot;fancypage.html&quot;);<br>        crow::mustache::context ctx({ {&quot;person&quot;, name} });<br>        return page.render(ctx);<br>     });<br>    CROW_ROUTE(app, &quot;/modulo/&lt;int&gt;/&lt;int&gt;&quot;)([](int a, int b) {<br>        std::string res = &quot;Answer of &quot; + std::to_string(a) + &quot; modulo &quot; + std::to_string(b) + &quot; is &quot; + std::to_string(a % b);<br>        return res;<br>    });<br> app.port(1808).multithreaded().run();<br>}</pre><p>This code will setup all the routes and ability to run the programs on port 1808.</p><p>Don’t worry about the weird syntax of lambdas in C++ , you will get comfortable with them eventually.</p><p>Now lets add the fancypage.html , click on the name of your project in solution explorer and click open in file explorer inside of which you need to create a folder named templates and inside of it create a file called fancypage.html and copy the following.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;body style=&quot;background-color:darkslategrey&quot;&gt;<br>    &lt;div style=&quot;display:flex; align-content:center&quot;&gt;<br>        &lt;h1 style=&quot;color:navajowhite;&quot;&gt;Hello, {{person}}!&lt;/h1&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Now lets run our project</h3><p>Click on the little green icon on the top of the Editor and it will build and run the code. You can access the page in your browser at localhost:1808 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbQm5uWOAG7yOe28KWaKOg.png" /></figure><p>The routes will work something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIM8sMAetQt-s2YXeXZWpw.png" /></figure><p>PS: It was an old build using port 18080 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RzwoW85vxM3qJ7mhA4xADA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_LGb5WsOLZMmPdaT5c5voQ.png" /></figure><p>I hope you found this blog helpful and build your crow project without any problems , if you need any help setting it up you can contact me.</p><h3>Enjoy building . Have A Good Day.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26ce0a2322af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SetUp Tailwind CSS in your Django project and avoid common pitfalls.]]></title>
            <link>https://medium.com/devdotcom/setup-tailwind-css-in-your-django-project-and-avoid-common-pitfalls-4b5063922562?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b5063922562</guid>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[setup]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Tue, 28 Jan 2025 12:49:19 GMT</pubDate>
            <atom:updated>2025-01-28T12:49:19.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GL5SY1lqsVS29Bi7XfdMSg.jpeg" /></figure><p>Setting up <strong>Tailwind CSS</strong> for your <strong>Django</strong> project can be a daunting task but it is equally rewarding , it eliminates the need for writing CSS classes yourselves.</p><p>Let’s start and make our frontend awe inspiring.</p><p>Step 1.</p><p>First and foremost you need to install the python package for Tailwind CSS, for that simply cd into your root folder same level as the .venv file and enter the command . ( Don’t forget to activate your virtual environment ).</p><pre>pip install django-tailwind</pre><p>Now configure tailwind by opening the main app which <em>has the same name as your project</em>. Go to the settings.py and under INSTALLED_APPS add tailwind .</p><pre>python manage.py tailwind init</pre><p>This will create a new app in your root directory named theme.</p><p>Step 2.</p><p>Now install the theme app by opening the main app which <em>has the same name as your project</em>. Go to the settings.py and under INSTALLED_APPS add theme .</p><p>Now add these two fields below at the end of the file.</p><pre>TAILWIND_APP_NAME = &#39;theme&#39;<br>INTERNAL_IPS = [&#39;127.0.0.1&#39;]</pre><p>You need to give the bin path for node as well, because Tailwind works with npm in the backend.</p><pre>NPM_BIN_PATH = &quot;C:\\Program Files\\nodejs\\npm.cmd&quot;</pre><p>Now run the command to ensure tailwind is setup for project.</p><pre>python manage.py tailwind install</pre><p>Step 3.</p><p>Django-Tailwind comes with its own template to be directly used as any other Django template. To start using it in any of your .html files, under templates folder open your html file and you simply need to add {% load static tailwind_tags% } and {% tailwind_css %} inside the head tag of your html page. It should look something like this.</p><pre>{% load static tailwind_tags %}<br>...<br>&lt;head&gt;<br>   ...<br>   {% tailwind_css %}<br>   ...<br>&lt;/head&gt;</pre><p>If you have a layout.html file simply repeat the steps to maintain consistency.</p><p>Step 5.</p><p>Start using Tailwind CSS by adding class= to your html tags.</p><pre>&lt;h1 class=&quot;bg-orange-500 text-3xl p-2&quot;&gt;Chai aur code | Homepage&lt;/h1&gt;</pre><p>You won’t see any changes as we have to start Tailwind to constantly configure CSS files on the go.</p><p>Simply open a new window in terminal and enter the command.</p><pre>python manage.py tailwind start</pre><p>Notes:- If you even face the issue where python manage.py &lt;&gt; is invalid , just cd &lt;your_project_name&gt; and then run the command.</p><h3><strong>Thank you</strong> for reading the blog up until this point .</h3><h4>I hope you found this blog useful . This blog is more of a note for me to remember setting up tailwind at some later point in time.</h4><p>Checkout the fully configured project at : <a href="https://github.com/Adityasinghvats/Django-learning/tree/main/blog">Django-learning/blog at main · Adityasinghvats/Django-learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b5063922562" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devdotcom/setup-tailwind-css-in-your-django-project-and-avoid-common-pitfalls-4b5063922562">SetUp Tailwind CSS in your Django project and avoid common pitfalls.</a> was originally published in <a href="https://medium.com/devdotcom">devdotcom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating ER Diagrams for Development]]></title>
            <link>https://medium.com/devdotcom/creating-er-diagrams-for-development-1153f99a56af?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/1153f99a56af</guid>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Sat, 19 Oct 2024 03:09:43 GMT</pubDate>
            <atom:updated>2024-10-19T03:09:43.440Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*LJ_OaYwyOXXEBtQEkiunRA.png" /></figure><p>This blog explores creating ER (Entity Relationships) diagram for use in database modelling. You may be using an ORM (Object Relation Mapper) like mongoose, drizzle, prisma, hibernate, exposed, Room , etc. or writing raw SQL queries. A clear understanding of project needs beforehand is crucial.</p><h4>1. Tools</h4><p>There are many tools including paid and profession tools , but we will be using a free tool called <strong>Eraser.io</strong> , it is free for individual usage , but use it carefully as it only provides 5 free projects. Simply go to the website , create an account , and then create a project .</p><h4>2.Usage</h4><p>To starting using it , open your project, in the <strong>side bar</strong> you will find a ‘ +’ icon click on it and choose <strong>diagram as code</strong> , then choose <strong>ER diagram</strong>. Then <strong>double-click on the diagram</strong> to open the code section and delete all .</p><p>Syntax:</p><pre>users -&gt; naming the table<br>[ ] -&gt; specification of table<br>{ } -&gt; fileds of table inside this part<br>&#39;-&#39; -&gt; one to one relationship<br>&#39;&gt;&#39; -&gt; many to one relationship<br>&#39;&lt;&#39; -&gt; one to many relationship<br>&#39;&lt;&gt;&#39; -&gt; many to many relationship</pre><h4><strong>3.Creating a diagram</strong></h4><p>We will be creating a simple payment system for learning . First, create all table using the code. Add id in each table , which will be a string as primary key.</p><pre>users[icon: user, color: red]{<br>id string pk<br>}<br>payment[icon: user, color: blue]{<br>id string pk<br>}<br>paymenthistory[icon: user, color: green]{<br>id string pk<br>}</pre><p>Now think and start adding fields in the table and define their datatypes as well.</p><pre>users[icon: user, color: red]{<br>id string pk<br>username string<br>email string<br>password string<br>history ObjectId paymenthistory<br>}<br><br>payments[icon: user, color: blue]{<br>id string pk<br>user ObjectId users<br>amount number<br>semester string<br>status enum &quot;Paid&quot; &quot;Pending&quot; &quot;Not Paid&quot;<br>createdAt time<br>}<br><br>paymenthistory[icon: user, color: green]{<br>id string pk<br>allpayment ObjectId[] payments<br>totalamount number[] amount<br>semester string<br>createdAt time<br>}</pre><blockquote>ObjectId [ ] users -&gt; array of id of users</blockquote><blockquote>pk -&gt; primary key</blockquote><p>Now we can start defining relationships using the code.</p><pre>users.history - paymenthistory.id<br>paymenthistory.allpayment &lt; payments.id<br>payments.user - users.id<br>paymenthistory.createdAt - payments.createdAt<br>paymenthistory.semester - payments.semester<br>paymenthistory.totalamount &lt; payments.amount</pre><h4>Final Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h70Mhcpkn3bm8cB5agbzEQ.png" /></figure><h4>Conclusion</h4><p>Congratulations 🙌 on creating your first ER model.</p><p>If you found the blog informative , vote for it , and you can comment your suggestions as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1153f99a56af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devdotcom/creating-er-diagrams-for-development-1153f99a56af">Creating ER Diagrams for Development</a> was originally published in <a href="https://medium.com/devdotcom">devdotcom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Mobile App Development]]></title>
            <link>https://medium.com/devdotcom/introduction-to-mobile-app-development-c94d58f110a0?source=rss-4979476224ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/c94d58f110a0</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[AdityaSinghVats]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 09:32:12 GMT</pubDate>
            <atom:updated>2024-10-13T09:32:12.778Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-FfIJX2HnhLMUv7q.png" /></figure><p>In the world of software development , every field of development goes through a cycle of hype and then eventual adoption . Nowadays , there is hype as well as actual need for ML Developers, DevOps , MERN , AI Developers . But there are many such fields , which go unnoticed by the students like Embedded Systems Development, Network Engineering , other full-stack paradigms like Java-Spring Boot , PHP Stack , Ruby On Rails , etc.</p><p>In this blog , I would like to draw your attention towards , one such less talked about stack , i.e. Mobile App Development.</p><h3>1. Brief History</h3><p>Before 2008 launch of first iPhone , everything about internet was just website and webapps . But the introduction of app marketplace and handheld compute devices changed the game forever. Apple started their marketplace called AppStore , soon Android came up with Play Store. Android is an open source operating system build on top of Linux Kernel Upstream. Today I will be talking about , the modern day app development tools required for making your own mobile app for Android Platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Cy0rxm5ZQZfIn_Ij1Eic0g.png" /></figure><h3>2. Basic Requirements</h3><ol><li>Kotlin — A statically typed modern programming language , with OOPS as well as functional paradigms , it is a JVM language and backwards compatible with Java packages and libraries. It was introduced as a replacement of Java by Google and JetBrains . Google made it the official language for Android Development.</li><li>Android Studio — Official IDE for Android Development , once again by JetBrains , it can also be used to work with AOSP and NDK parts of Android, it offers a Device Emulator , Networking Capabilites and much more.</li></ol><h3>3. Creating UI/UX and Functionality</h3><p>Jetpack Compose — In the world of Android , you have two options , either you can build the components using the Views or Jetpack Compose . You can start with Views if you are coming from web development , as it is a natural progression . Nowadays every new project and most of the old projects have adopted Jetpack Compose. Jetpack Compose is a declarative UI framework which provides components , navigation , architecture and much more.</p><h3>4. Data Persistence and Networking</h3><ol><li>Data Persistence — Mobile Apps are built with the offline — first approach , so data persistence in offline mode is necessary . As mobile devices are resource constraints , sqlite3 is used for storing data . You can either write SQL queries or use DAOs by using Room DB , it is a kind of ORM.</li><li>Networking — Mobile app also need to access the internet and make API calls , for this purpose the most widely used framework is OkHTTP , Retrofit and Ktor .</li></ol><h3>5. Backend Functionality</h3><p>Firebase / Appwrite / Supabase — All these services provide Backend as a Service (BaaS) , writing a custom backend is a viable but as of now we need to focus on building our app rather than complexities of backend framework , database , scaling , deployment etc. Firebase is a google service , which provides a serverless compute , NoSQL database , analytics , real time database , cloud messaging and many more . App write is an open source alternative to Firebase , with much more easy to use SDKs and lower pricing and no vendor lock-in.</p><h3>6. Deployment</h3><p>Deployment of Android apps is not as complex as provisioning a VPC, setting up servers , etc. . Both Android and iOS provide a marketplace for publishing apps and manages the distribution for developers . Your app must adhere with all the guidelines of the marketplace.</p><p>Thank you for reading up to this point .😁</p><p>This is my first blog , so let me know your suggestions . I have intentionally left the nitty gritty of Android including many topics like Kotlin language , Jetpack Compose , XML views , Work Manager , Coroutines , Flows, Integration and Unit testing , Accessibility ,as it will be overwhelming and too long for readers , who nowadays have very low attention span.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c94d58f110a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devdotcom/introduction-to-mobile-app-development-c94d58f110a0">Introduction to Mobile App Development</a> was originally published in <a href="https://medium.com/devdotcom">devdotcom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>