{"id":294,"date":"2024-07-28T21:37:17","date_gmt":"2024-07-28T16:07:17","guid":{"rendered":"https:\/\/dctn.in\/?p=294"},"modified":"2024-07-28T21:37:17","modified_gmt":"2024-07-28T16:07:17","slug":"tod-service-time-of-the-day","status":"publish","type":"post","link":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/","title":{"rendered":"TOD Service &#8211; Time of the Day"},"content":{"rendered":"\n<p><mark style=\"background-color:#7bdcb5\" class=\"has-inline-color\">Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time.<\/mark><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Implement a TOD Service on a Server<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a Socket<\/strong>: Set up a TCP socket to listen for incoming connections.<\/li>\n\n\n\n<li><strong>Bind the Socket<\/strong>: Bind the socket to a specific IP address and port.<\/li>\n\n\n\n<li><strong>Listen for Connections<\/strong>: Set the socket to listen for incoming connection requests.<\/li>\n\n\n\n<li><strong>Accept Connections<\/strong>: Accept incoming client connections and handle them.<\/li>\n\n\n\n<li><strong>Send the Time<\/strong>: Send the current date and time to the connected client.<\/li>\n\n\n\n<li><strong>Close the Connection<\/strong>: Close the connection after sending the data.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Code snippet<\/h3>\n\n\n\n<p>complete example of a simple ToD service written in C can be found at below <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>#include &lt;stdio.h>\n#include &lt;stdlib.h>\n#include &lt;string.h>\n#include &lt;unistd.h>\n#include &lt;arpa\/inet.h>\n#include &lt;time.h>\n\n#define PORT 45000  \/\/ The port number on which the ToD service will listen\n#define BUFFER_SIZE 128  \/\/ variable size buffer\n\nint main() {\n    int server_fd, client_fd;\n    struct sockaddr_in server_addr, client_addr;\n    socklen_t client_addr_len = sizeof(client_addr);\n    char buffer&#91;BUFFER_SIZE];\n    time_t current_time;\n    struct tm *local_time;\n    int bytes_sent;\n\n    \/\/ Create a socket\n    if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n        perror(\"socket\");\n        exit(EXIT_FAILURE);\n    }\n\n    \/\/ Prepare the sockaddr_in structure\n    server_addr.sin_family = AF_INET;\n    server_addr.sin_addr.s_addr = INADDR_ANY;  \/\/ Bind to all available interfaces including lo interface \n    server_addr.sin_port = htons(PORT);  \/\/ Port number in network byte order\n\n    \/\/ Bind the socket to the address and port\n    if (bind(server_fd, (struct sockaddr *)&amp;server_addr, sizeof(server_addr)) == -1) {\n        perror(\"bind\");\n        close(server_fd);\n        exit(EXIT_FAILURE);\n    }\n\n    \/\/ Listen for incoming connections\n    if (listen(server_fd, 5) == -1) {\n        perror(\"listen\");\n        close(server_fd);\n        exit(EXIT_FAILURE);\n    }\n\n    printf(\"Server listening for CLIENT request on port %d...\\n\", PORT);\n\n    while (1) {\n        \/\/ Accept an incoming connection\n        if ((client_fd = accept(server_fd, (struct sockaddr *)&amp;client_addr, &amp;client_addr_len)) == -1) {\n            perror(\"accept\");\n            close(server_fd);\n            exit(EXIT_FAILURE);\n        }\n\n        \/\/ Get the current time\n        current_time = time(NULL);\n        local_time = localtime(&amp;current_time);\n\n        \/\/ copy the formatted time into buffer\n        snprintf(buffer, BUFFER_SIZE, \"Current time: %s\", asctime(local_time));\n\n        \/\/ Send copied buffer to the client\n        bytes_sent = send(client_fd, buffer, strlen(buffer), 0);\n        if (bytes_sent == -1) {\n            perror(\"send\");\n        }\n\n        \/\/ current client requested connection closed\n        close(client_fd);\n    }\n\n    \/\/ server socket is closed\n    close(server_fd);\n    return 0;\n}\n<\/code><\/code><\/pre>\n\n\n\n<div class=\"wp-block-media-text is-stacked-on-mobile\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"143\" src=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/timer_output.gif\" alt=\"\" class=\"wp-image-298 size-full\"\/><\/figure><div class=\"wp-block-media-text__content\">\n<p>Tick Tick Tick &#8230;<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">simplify above code<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Socket Creation<\/strong>: <code>server_fd = socket(AF_INET, SOCK_STREAM, 0); <\/code>Creates a TCP socket. <br>Wondering why we didn&#8217;t choose UDP sockets ? <\/li>\n\n\n\n<li><strong>Binding<\/strong>: <code>server_addr.sin_family = AF_INET;<\/code><br>               <code>server_addr.sin_addr.s_addr = INADDR_ANY; <\/code><br>        <code>    server_addr.sin_port = htons(PORT); <\/code><br><br>             <code>bind(server_fd, (struct sockaddr *)&amp;server_addr, sizeof(server_addr)); <\/code><br>Binds the socket to all available interfaces on the specified port.<\/li>\n\n\n\n<li><strong>Listening<\/strong>: <code>listen(server_fd, 5); <\/code>Sets the socket to listen for incoming connections, with a backlog queue size of 5 <br>use below command on Linux to know more about listen system call<br>man listen<\/li>\n\n\n\n<li><strong>Accepting Connections<\/strong>: <code>client_fd = accept(server_fd, (struct sockaddr *)&amp;client_addr, &amp;client_addr_len); <\/code><br>Accepts an incoming connection from a client.<\/li>\n\n\n\n<li><strong>Sending the Time<\/strong>: <code>current_time = time(NULL); <\/code><br><code>local_time = localtime(&amp;current_time); <\/code><br><code>snprintf(buffer, BUFFER_SIZE, \"Current time: %s\", asctime(local_time)); send(client_fd, buffer, strlen(buffer), 0); <\/code><br>Retrieves the current time, formats it, and sends it to the client.<\/li>\n\n\n\n<li><strong>Closing Connections<\/strong>: <code>close(client_fd); close(server_fd); <\/code><br>Closes the client connection and server socket.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">run services on server <\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Compile the Code<\/strong>  <code>gcc -o tod_daemon tod_server.c<\/code><\/li>\n\n\n\n<li><strong>Run the Server<\/strong>: <code>.\/tod<\/code>_<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">daemon<\/mark> use &#8220;netstat -tulpen&#8221; command to check\/verify whether process is listening on the port or not  <\/li>\n\n\n\n<li><strong>Connect to the Server<\/strong>: Send client request to fetch the ToD and You should see the current date and time displayed by the server.<\/li>\n<\/ol>\n\n\n\n<p>Please write your own TOD client in C language to test the ToD service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Code snippet complete example of a simple ToD service written in C can be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-blog"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"dctn.in\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Next Gen Innovation | DCTN - Reliable Communication\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN\" \/>\n\t\t<meta property=\"og:description\" content=\"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-07-28T16:07:17+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-07-28T16:07:17+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#blogposting\",\"name\":\"TOD Service \\u2013 Time of the Day - Next Gen Innovation | DCTN\",\"headline\":\"TOD Service &#8211; Time of the Day\",\"author\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/author\\\/dctn-in\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/dctn.in\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/timer_output.gif\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#articleImage\",\"width\":500,\"height\":143},\"datePublished\":\"2024-07-28T21:37:17+05:30\",\"dateModified\":\"2024-07-28T21:37:17+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#webpage\"},\"articleSection\":\"Blog\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dctn.in\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/category\\\/blog\\\/#listItem\",\"name\":\"Blog\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/category\\\/blog\\\/#listItem\",\"position\":2,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/category\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#listItem\",\"name\":\"TOD Service &#8211; Time of the Day\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#listItem\",\"position\":3,\"name\":\"TOD Service &#8211; Time of the Day\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/category\\\/blog\\\/#listItem\",\"name\":\"Blog\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/dctn.in\\\/#organization\",\"name\":\"dctn.in\",\"description\":\"Reliable Communication\",\"url\":\"https:\\\/\\\/dctn.in\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/dctn.in\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/cropped-logo_dctn.png\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#organizationLogo\",\"width\":240,\"height\":240},\"image\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/author\\\/dctn-in\\\/#author\",\"url\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/author\\\/dctn-in\\\/\",\"name\":\"dctn.in\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e14f24da79a5f74b011bc007fd57e9383da77ec09361c98e69e7fe0f7e455719?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"dctn.in\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#webpage\",\"url\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/\",\"name\":\"TOD Service \\u2013 Time of the Day - Next Gen Innovation | DCTN\",\"description\":\"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/blog\\\/tod-service-time-of-the-day\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/author\\\/dctn-in\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/index.php\\\/author\\\/dctn-in\\\/#author\"},\"datePublished\":\"2024-07-28T21:37:17+05:30\",\"dateModified\":\"2024-07-28T21:37:17+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dctn.in\\\/#website\",\"url\":\"https:\\\/\\\/dctn.in\\\/\",\"name\":\"dctn.in\",\"description\":\"Reliable Communication\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/dctn.in\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN","description":"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind","canonical_url":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#blogposting","name":"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN","headline":"TOD Service &#8211; Time of the Day","author":{"@id":"https:\/\/dctn.in\/index.php\/author\/dctn-in\/#author"},"publisher":{"@id":"https:\/\/dctn.in\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/timer_output.gif","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#articleImage","width":500,"height":143},"datePublished":"2024-07-28T21:37:17+05:30","dateModified":"2024-07-28T21:37:17+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#webpage"},"isPartOf":{"@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#webpage"},"articleSection":"Blog"},{"@type":"BreadcrumbList","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/dctn.in\/#listItem","position":1,"name":"Home","item":"https:\/\/dctn.in\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dctn.in\/index.php\/category\/blog\/#listItem","name":"Blog"}},{"@type":"ListItem","@id":"https:\/\/dctn.in\/index.php\/category\/blog\/#listItem","position":2,"name":"Blog","item":"https:\/\/dctn.in\/index.php\/category\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#listItem","name":"TOD Service &#8211; Time of the Day"},"previousItem":{"@type":"ListItem","@id":"https:\/\/dctn.in\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#listItem","position":3,"name":"TOD Service &#8211; Time of the Day","previousItem":{"@type":"ListItem","@id":"https:\/\/dctn.in\/index.php\/category\/blog\/#listItem","name":"Blog"}}]},{"@type":"Organization","@id":"https:\/\/dctn.in\/#organization","name":"dctn.in","description":"Reliable Communication","url":"https:\/\/dctn.in\/","logo":{"@type":"ImageObject","url":"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#organizationLogo","width":240,"height":240},"image":{"@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/dctn.in\/index.php\/author\/dctn-in\/#author","url":"https:\/\/dctn.in\/index.php\/author\/dctn-in\/","name":"dctn.in","image":{"@type":"ImageObject","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e14f24da79a5f74b011bc007fd57e9383da77ec09361c98e69e7fe0f7e455719?s=96&d=mm&r=g","width":96,"height":96,"caption":"dctn.in"}},{"@type":"WebPage","@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#webpage","url":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/","name":"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN","description":"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/dctn.in\/#website"},"breadcrumb":{"@id":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/#breadcrumblist"},"author":{"@id":"https:\/\/dctn.in\/index.php\/author\/dctn-in\/#author"},"creator":{"@id":"https:\/\/dctn.in\/index.php\/author\/dctn-in\/#author"},"datePublished":"2024-07-28T21:37:17+05:30","dateModified":"2024-07-28T21:37:17+05:30"},{"@type":"WebSite","@id":"https:\/\/dctn.in\/#website","url":"https:\/\/dctn.in\/","name":"dctn.in","description":"Reliable Communication","inLanguage":"en-US","publisher":{"@id":"https:\/\/dctn.in\/#organization"}}]},"og:locale":"en_US","og:site_name":"Next Gen Innovation | DCTN - Reliable Communication","og:type":"article","og:title":"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN","og:description":"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind","og:url":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/","og:image":"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png","og:image:secure_url":"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png","article:published_time":"2024-07-28T16:07:17+00:00","article:modified_time":"2024-07-28T16:07:17+00:00","twitter:card":"summary_large_image","twitter:title":"TOD Service \u2013 Time of the Day - Next Gen Innovation | DCTN","twitter:description":"Writing a basic Time-of-the-Day (TOD) server is a good experiment for learning basic network programming concepts. A TOD server listens for incoming network connections and responds with the current date and time. Steps to Implement a TOD Service on a Server Create a Socket: Set up a TCP socket to listen for incoming connections. Bind","twitter:image":"https:\/\/dctn.in\/wp-content\/uploads\/2024\/07\/cropped-logo_dctn.png"},"aioseo_meta_data":{"post_id":"294","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-07-28 15:52:00","updated":"2025-08-17 16:21:15","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dctn.in\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/dctn.in\/index.php\/category\/blog\/\" title=\"Blog\">Blog<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tTOD Service \u2013 Time of the Day\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/dctn.in\/"},{"label":"Blog","link":"https:\/\/dctn.in\/index.php\/category\/blog\/"},{"label":"TOD Service &#8211; Time of the Day","link":"https:\/\/dctn.in\/index.php\/blog\/tod-service-time-of-the-day\/"}],"_links":{"self":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/comments?post=294"}],"version-history":[{"count":4,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/posts\/294\/revisions\/299"}],"wp:attachment":[{"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dctn.in\/index.php\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}