Recent

Author Topic: Hiring... Maybe..  (Read 18752 times)

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #30 on: September 16, 2015, 02:49:42 am »
Unsure. Is that the Fulgan version or CT version?

You dont actually have to install Indy. As long as you set those 3 paths, everything works.

But, yes, if people like the dropable component icons, then, the CT package seems to be the best way togo. Plus, you get all the other goodies from CT.


aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #31 on: September 16, 2015, 02:55:38 am »
I'm trying the CT version.

I can get it to run but I get the following message when running from Lazarus IDE:

Code: [Select]
Project Project1 raised exception class 'EIdSocketError' with message:
Socket Error # 13
Access denied.

In file '../.././../pl_Indy/source/IdStack.pas' at line 905:
raise EIdSocketError.CreateError(AErr, WSTranslateSocketErrorMsg(AErr));

And when running from Terminal as SU I get the following error:

Code: [Select]
Semaphore init failed (possibly to any concurrent threads).
Press OK  blablablabla
Press Cancel blablablabla

Should I try the Fulgan version?

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #32 on: September 16, 2015, 03:06:31 am »
Is that the server or client? Do you have the server running?

Socket Error # 13 is a port error. the default HTTP port is 80, which maybe you are already using.

Try another port.

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #33 on: September 16, 2015, 03:09:37 am »
Just to make sure you know. Make sure you check that code. It has a DeleteFile command and a fmCreate based TFileStream. Both can delete files.

You also need a http folder where your exe is, and there is no ForceDirectory, so PUT-ing files to non-existant directories will fail.

The code is just an example of a concept. Make sure you read it all before using it.

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #34 on: September 16, 2015, 03:21:32 am »
Ok I tried the Fulgan version and inside the project source I defined "cthreads" in the uses clause section.

Now it seems to be running properly.

Now I just have to do some testing.

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #35 on: September 16, 2015, 04:26:58 am »
Ok I'm testing your code now.

I think the server is running properly on my Linux distro, but the client, which is running on my Mac, doesn't seem to work properly.

With your code I call
Code: [Select]
Log(HttpGet('http://www.google.com/'));
And all I get is
Code: [Select]
HTTP/1.1 302 Found
When I call your original code which looks like this (with slight modification)
Code: [Select]
SendFile('http://198.168.1.39:1033/', opendialog1.filename, $1000000);
the client just hangs.

What could be the problem?

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #36 on: September 16, 2015, 04:46:39 am »
Code: [Select]
Log(HttpGet('http://www.google.com/'));And all I get is
Code: [Select]
HTTP/1.1 302 Found

HTTP 302 is a redirection. TIdHTTP doesn't redirect by default. Not only that, Google redirects to HTTPS, so you cant use TIdHTTP without HTTPS support. Put it simply, Google deliberately makes it hard to grab pages from them, using referer checks, encoded URL's, useragent checks. The only way Ive managed to access Google these days is via browser automation.

Quote
When I call your original code which looks like this (with slight modification)
Code: [Select]
SendFile('http://198.168.1.39:1033/', opendialog1.filename, $1000000); the client just hangs. What could be the problem?

Unsure. You haven't provided a document in the URL, and I didn't implement variable ports. ie:
This code should also include the port number, but it doesn't:
Code: [Select]
LRemotePath := AURI.Protocol + '://' + AURI.Host + AURI.Path;   

NOTE: Indy should have failed with an exception with that URL "http://198.168.1.39:1033". It would have been rebuilt as "http://198.168.1.39", which would have failed on the first PUT. Have you taken code out?
« Last Edit: September 16, 2015, 04:51:27 am by Geepster »

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #37 on: September 16, 2015, 04:52:16 am »
But I couldn't run the server on its default port, and you suggested to change the port, which I did.

So how am I supposed to access the server if I can't specify the port in the client?

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #38 on: September 16, 2015, 04:57:14 am »
Write some code? :o

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #39 on: September 16, 2015, 05:02:56 am »
Hahaha ofcourse I'm trying, but I can't find any property which defines the client port.

I tried the following code but still no luck:

Code: [Select]
function HttpGet(const AUrl: String): String;
    var idh: TIdHTTP;
begin
    idh := TIdHTTP.Create(nil);
    idh.BoundPort:=8080;
      try
        Result := idh.Get(AUrl);
        Log('HttpGet = ' + result);
      finally
        idh.Free;
      end;
end; 

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #40 on: September 16, 2015, 05:18:31 am »
Hahaha ofcourse I'm trying, but I can't find any property which defines the client port.
I tried the following code but still no luck:

Its easy. Its all part of the URL. http://host:port/path/document

Might help todo some research on URL syntax. URL's are quite powerful beasts
https://en.wikipedia.org/wiki/Uniform_Resource_Locator

Quote
scheme:[//[user:password@]domain[:port]][/]path[?query][#fragment]

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #41 on: September 16, 2015, 06:05:52 am »
Well not easy enough. I can't figure it out, and I've been working on it for hours now.

Ok let me ask you this, how do I send a simple string to the HTTP server at port 1033 or whatever using your code?

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #42 on: September 16, 2015, 06:24:17 am »
Ok let me ask you this, how do I send a simple string to the HTTP server at port 1033 or whatever using your code?

Umm. Not quite the right question. You should be asking, how do I send a string using TIdHTTP

Its the same way a browser submit's a HTML FORM. You would have seen it millions of times in the address bar.
Code: Pascal  [Select][+][-]
  1.     with TIdHTTP.Create(nil) do begin
  2.       try
  3.         Result := Get('http://127.0.0.1:1033/mydocument?str=HERE IS A STRING');
  4.       finally
  5.         Free;
  6.       end;
  7.     end;  
  8.  

You pick up the string at the server using:
Code: Pascal  [Select][+][-]
  1. ARequestInfo.Params.Values['str']
  2.  

For larger messages, use TIdHTTP.Post. If you want more complex messages, POST XML.

PUT, is a little obsolete, since POST does everything PUT does. The difference is, POST is supported by HTML FORM's, while PUT isn't. So, PUT can be used as a private gateway for file transfers. (NOTE: Where do you think the name putlocker comes from?)

This is all basic HTTP stuff. HTTP is just a standard protocol which sits on top of TCP. Because its standard, every language supports it.

http://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part-1--net-31177

I guessing you haven't coded any PHP FORM stuff? Or, if you have you haven't connected the dots?
« Last Edit: October 02, 2015, 03:07:45 am by Geepster »

aidv

  • Full Member
  • ***
  • Posts: 173
Re: Hiring... Maybe..
« Reply #43 on: September 16, 2015, 06:36:54 am »
Thanks.

And no.

I'm not a HTTP guru haha, I don't know much about it if anything at all.

derek.john.evans

  • Guest
Re: Hiring... Maybe..
« Reply #44 on: September 16, 2015, 06:42:56 am »
Thanks. And no. I'm not a HTTP guru haha, I don't know much about it if anything at all.

Thats cool. Considering Wikipedia says "HTTP is the foundation of data communication for the World Wide Web", I'd say it is something worth learning.

 

TinyPortal © 2005-2018