PHP to D Conversion

Vino akashvino79 at gmail.com
Mon Oct 21 11:36:00 UTC 2019


On Saturday, 19 October 2019 at 20:40:36 UTC, Boris Carvajal 
wrote:
> On Saturday, 19 October 2019 at 19:08:45 UTC, Vino wrote:
>> On Friday, 18 October 2019 at 14:56:05 UTC, Andre Pany wrote:
>>> On Friday, 18 October 2019 at 09:21:46 UTC, Vino wrote:
>>>> On Friday, 18 October 2019 at 09:17:24 UTC, Vino wrote:
>>>>> [...]
>>>>
>>>> And now getting the error : Program exited with code 
>>>> -1073741819
>>>
>>> Hi,
>>>
>>> Maybe port 8080 is blocked, because there is an instance of 
>>> your application running on the background. Just check by 
>>> changing the port in the source code.
>>>
>>> Kind regards
>>> Andre
>>
>> Hi Andre,
>>
>>   Tried with different ports still no luck getting this error 
>> : Program exited with code -1073741819.
>>
>> From,
>> Vino.B
>
> Your program is crashing probably because you are dereferencing 
> a null/ dangling pointer.
> Build your program in debug mode and run it in a debugger, that 
> way you will get a backtrace telling you the exactly line of 
> the code when it happens.

Hi Boris,

   I tired to build the code in debug mode and ran the program in 
debugger , the debugger is complaining about the line "this.conn 
= new Connection(connectionStr);", not sure what is wrong in the 
below code, hence request your help. Have the checked the 
connection string and the info is correct.

import vibe.vibe;
import mysql;
import std.array : array;
import std.conv;
import std.variant;

class avmtest
{
     private Connection conn;
     auto avmconnect()
     {
       auto connectionStr = 
"host=test.srv.com;port=3910;user=testusr;pwd=xxxx#;db=test";
       this.conn = new Connection(connectionStr);
     }
	
     auto getHostname()
     {
      ResultRange qdata = conn.query("SELECT host_name FROM 
`hosts_coll`");
      Row row = qdata.front;
      Variant h = row[0];
      qdata.close();
      return h.to!string;
    }
}

void hello(HTTPServerRequest req, HTTPServerResponse res)
{
  auto t = new avmtest();
  res.writeBody(t.getHostname);
}

void main()
{
   auto settings = new HTTPServerSettings;
   settings.port = 8130;
   settings.bindAddresses = ["127.0.0.1"];
   listenHTTP(settings, &hello);
   logInfo("Please open http://127.0.0.1:8130/ in your browser.");
   runApplication();
}

From,
Vino.B


More information about the Digitalmars-d-learn mailing list