diff --git a/examples/platform-posix/client/test.txt b/examples/platform-posix/client/test.txt new file mode 100644 index 0000000..f5d40ce --- /dev/null +++ b/examples/platform-posix/client/test.txt @@ -0,0 +1,494 @@ +Connected to google. +HTTP request sent. +HTTP/1.1 200 OK +Date: Thu, 02 Apr 2026 00:59:19 GMT +Expires: -1 +Cache-Control: private, max-age=0 +Content-Type: text/html; charset=ISO-8859-1 +Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-FvUPT_R6ZOVMh7e-eUqyYg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp +Reporting-Endpoints: default="//www.google.com/httpservice/retry/jserror?ei=Z7_NaYXBHM3rhbIPxduJ0AM&cad=crash&error=Page%20Crash&jsel=1&bver=2415" +Server: gws +X-XSS-Protection: 0 +X-Frame-Options: SAMEORIGIN +Set-Cookie: AEC=AaJma5v0cVPxDipUhUORZepdkAKP5luifkGeQ8I0Bf78HU2-c3nObvMQpF8; expires=Tue, 29-Sep-2026 00:59:19 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax +Accept-Ranges: none +Vary: Accept-Encoding +Transfer-Encoding: chunked + +8000 +Google



 0;){var a=this.i.pop();if(a in this.o)return a}return null};$b.prototype.getNext=$b.prototype.j;Pb("globalThis",function(a){return a||Lb});Pb("Reflect.setPrototypeOf",function(a){return a?a:Ub?function(b,c){try{return Ub(b,c),!0}catch(d){return!1}}:null}); +Pb("Symbol",function(a){if(a)return a;var b=function(f,g){this.i=f;Jb(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.i};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("g");return new b(c+(f||"")+"_"+d++,f)};return e});Pb("Symbol.iterator",function(a){if(a)return a;a=Symbol("h");Jb(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ac(Vb(this))}});return a}); +var ac=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}; +Pb("Promise",function(a){function b(){this.i=null}function c(g){return g instanceof e?g:new e(function(h){h(g)})}if(a)return a;b.prototype.j=function(g){if(this.i==null){this.i=[];var h=this;this.o(function(){h.A()})}this.i.push(g)};var d=Lb.setTimeout;b.prototype.o=function(g){d(g,0)};b.prototype.A=function(){for(;this.i&&this.i.length;){var g=this.i;this.i=[];for(var h=0;h

Advanced search

Google offered in: Gaeilge

© 2026 - 0;){var a=this.i.pop();if(a in this.o)return a}return null};$b.prototype.getNext=$b.prototype.j;Pb("globalThis",function(a){return a||Lb});Pb("Reflect.setPrototypeOf",function(a){return a?a:Ub?function(b,c){try{return Ub(b,c),!0}catch(d){return!1}}:null}); +Pb("Symbol",function(a){if(a)return a;var b=function(f,g){this.i=f;Jb(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.i};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("g");return new b(c+(f||"")+"_"+d++,f)};return e});Pb("Symbol.iterator",function(a){if(a)return a;a=Symbol("h");Jb(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ac(Vb(this))}});return a}); +var ac=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}; +Pb("Promise",function(a){function b(){this.i=null}function c(g){return g instanceof e?g:new e(function(h){h(g)})}if(a)return a;b.prototype.j=function(g){if(this.i==null){this.i=[];var h=this;this.o(function(){h.A()})}this.i.push(g)};var d=Lb.setTimeout;b.prototype.o=function(g){d(g,0)};b.prototype.A=function(){for(;this.i&&this.i.length;){var g=this.i;this.i=[];for(var h=0;hPrivacy - Terms

Google apps
+0 + +)};document.addEventListener(F,b,{passive:!0})}x||k()}else B()},0);})();window._ = window._ || {};window..D:this.j=a};_.D.prototype.leaveFinallyBlock=_.D.prototype.M;_.D.prototype.O=function(a){return new $b(a)};_.D.prototype.forIn=_.D.prototype.O; +var $b=function(a){this.o=a;this.i=[];for(var b in a)this.i.push(b);this.i.reverse()};$b.prototype.j=function(){for(;this.i.length>0;){var a=this.i.pop();if(a in this.o)return a}return null};$b.prototype.getNext=$b.prototype.j;Pb("globalThis",function(a){return a||Lb});Pb("Reflect.setPrototypeOf",function(a){return a?a:Ub?function(b,c){try{return Ub(b,c),!0}catch(d){return!1}}:null}); +Pb("Symbol",function(a){if(a)return a;var b=function(f,g){this.i=f;Jb(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.i};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("g");return new b(c+(f||"")+"_"+d++,f)};return e});Pb("Symbol.iterator",function(a){if(a)return a;a=Symbol("h");Jb(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ac(Vb(this))}});return a}); +var ac=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}; +Pb("Promise",function(a){function b(){this.i=null}function c(g){return g instanceof e?g:new e(function(h){h(g)})}if(a)return a;b.prototype.j=function(g){if(this.i==null){this.i=[];var h=this;this.o(function(){h.A()})}this.i.push(g)};var d=Lb.setTimeout;b.prototype.o=function(g){d(g,0)};b.prototype.A=function(){for(;this.i&&this.i.length;){var g=this.i;this.i=[];for(var h=0;hError 400 (Bad Request)!!1mpException;window.loaded_h_0 = function(cb){cb.call(window,window._);};(function(){var t=[128,0,16777216,0,0,1048576,33554432,202260488,4096,33554432,0,536871010,133092,151347264,276824576,872415232,2163458,0,262144,4194304,32,9363968,0,373309440,4,0,120,4096];window._F_toggles = window._xjs_toggles = t;})();window._F_installCss = window._F_installCss || function(css){};(function(){var pmc='{\x22d\x22:{},\x22sb_he\x22:{\x22client\x22:\x22heirloom-hp\x22,\x22dh\x22:true,\x22ds\x22:\x22\x22,\x22host\x22:\x22google.com\x22,\x22jsonp\x22:true,\x22lm\x22:true,\x22msgs\x22:{\x22cibl\x22:\x22Clear Search\x22,\x22dym\x22:\x22Did you mean:\x22,\x22lcky\x22:\x22I\\u0026#39;m Feeling Lucky\x22,\x22lml\x22:\x22Learn more\x22,\x22psrc\x22:\x22This search was removed from your \\u003Ca href\x3d\\\x22/history\\\x22\\u003EWeb History\\u003C/a\\u003E\x22,\x22psrl\x22:\x22Remove\x22,\x22sbit\x22:\x22Search by image\x22,\x22srch\x22:\x22Google Search\x22},\x22ovr\x22:{},\x22pq\x22:\x22\x22,\x22rfs\x22:[],\x22stok\x22:\x22PMJCkCIuyLrJlKs-PNH4mrS156I\x22}}';google.pmc=JSON.parse(pmc);})(); +0 + +)};document.addEventListener(F,b,{passive:!0})}x||k()}else B()},0);})();window._ = window._ || {};window..D:this.j=a};_.D.prototype.leaveFinallyBlock=_.D.prototype.M;_.D.prototype.O=function(a){return new $b(a)};_.D.prototype.forIn=_.D.prototype.O; +var $b=function(a){this.o=a;this.i=[];for(var b in a)this.i.push(b);this.i.reverse()};$b.prototype.j=function(){for(;this.i.length>0;){var a=this.i.pop();if(a in this.o)return a}return null};$b.prototype.getNext=$b.prototype.j;Pb("globalThis",function(a){return a||Lb});Pb("Reflect.setPrototypeOf",function(a){return a?a:Ub?function(b,c){try{return Ub(b,c),!0}catch(d){return!1}}:null}); +Pb("Symbol",function(a){if(a)return a;var b=function(f,g){this.i=f;Jb(this,"description",{configurable:!0,writable:!0,value:g})};b.prototype.toString=function(){return this.i};var c="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",d=0,e=function(f){if(this instanceof e)throw new TypeError("g");return new b(c+(f||"")+"_"+d++,f)};return e});Pb("Symbol.iterator",function(a){if(a)return a;a=Symbol("h");Jb(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ac(Vb(this))}});return a}); +var ac=function(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}; +Pb("Promise",function(a){function b(){this.i=null}function c(g){return g instanceof e?g:new e(function(h){h(g)})}if(a)return a;b.prototype.j=function(g){if(this.i==null){this.i=[];var h=this;this.o(function(){h.A()})}this.i.push(g)};var d=Lb.setTimeout;b.prototype.o=function(g){d(g,0)};b.prototype.A=function(){for(;this.i&&this.i.length;){var g=this.i;this.i=[];for(var h=0;h +//LIBC header for error and dynamic memory handling +#include +//POSIX header for socket data structure and methods +#include +#include +#include +//Preprocessor directive to link dynamic library into the application +//Can be done using make just added here for the purpose of the tutorial +#pragma comment(lib, "Ws2_32.lib") + +#define SERVER_MSG "Hi Bro!\n" +#define SERVER "127.0.0.1" +#define PORT 1500 //Using none standard port +#define CLIENT_LIMIT 5 //the limit is capped to 128 + +int main(int argc, char** argv){//start of main method + //define the address of where our server application exists +struct sockaddr_in serveraddr = { + .sin_family = AF_INET, + .sin_port = htons(PORT), + .sin_addr.s_addr = htonl(INADDR_ANY) +}; + +// Winsock startup +WSADATA wsaData; +// Winsock version 2.2 is requested +int result = WSAStartup(MAKEWORD(2,2), &wsaData); +if(result){ + fprintf(stderr, "WSAStartup() failed %d\n", result); + return EXIT_FAILURE; +} + + //create a socket +SOCKET socketfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); +if(socketfd == INVALID_SOCKET){ + fprintf(stderr, "Error: socket() %ld\n", WSAGetLastError()); + WSACleanup(); + return EXIT_FAILURE; +} + + //bind our application to the socket + if(bind(socketfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))){ + fprintf(stderr, "Error: bind() failed, code %ld\n", WSAGetLastError()); // WSAGetLastError() is the winsock equivalent of errno + closesocket(socketfd); + WSACleanup(); + return EXIT_FAILURE; +} + + //listen for connections + if(listen(socketfd, CLIENT_LIMIT)){ + fprintf(stderr, "Error: listen() failed, code %ld\n", WSAGetLastError()); + closesocket(socketfd); + WSACleanup(); + return EXIT_FAILURE; + } + + struct sockaddr clientaddr; + int clientaddr_size = sizeof(clientaddr); + //accept client - function yields until the backlog queue has at least one entry from which it will grab the top + SOCKET client_socket = accept(socketfd, &clientaddr, &clientaddr_size); + if(client_socket == INVALID_SOCKET){ + fprintf(stderr, "Error: accept() failed, code %ld\n", WSAGetLastError()); + closesocket(socketfd); + WSACleanup(); + return EXIT_FAILURE; +} + + char writeBuffer[100] = {0}; + snprintf(writeBuffer, sizeof(writeBuffer),"%s",SERVER_MSG); + // Send only what the string actually contains, not the entire buffer + result = send(client_socket, writeBuffer, (int)strlen(writeBuffer), 0); + if(result == SOCKET_ERROR){ + fprintf(stderr, "Error: send() failed, code %ld\n", WSAGetLastError()); + closesocket(client_socket); + closesocket(socketfd); + WSACleanup(); + return EXIT_FAILURE; +} + + closesocket(client_socket); + closesocket(socketfd); + WSACleanup(); + + return EXIT_SUCCESS; +}//end of main method + +/* +// Sources: +https://medium.com/@adityakumarbgs6/network-programming-part-1-using-winsock-programming-sockets-1978e4de94a2 +*/