FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 04, 2026 1:33 am

All times are UTC




Post new topic  Reply to topic  [ 12 posts ]  Go to page Previous 1 2
Author Message
PostPosted: Tue Jan 19, 2010 9:23 pm 
Offline
Tutorials Contributor
Tutorials Contributor
User avatar

Joined: Tue Jun 17, 2008 3:39 am
Posts: 59
Location: Midwest, US
Please share what you've found. It might be useful to others.

Thanks!

_________________
Don't look at me. I'm new here.


Top
   
PostPosted: Tue Jan 19, 2010 9:51 pm 
Offline

Joined: Fri Jan 01, 2010 6:39 pm
Posts: 19
so, my problem was in the freetopay server. when i have used a regular hosting, i take a correct answers...

this is full code of test program, based on the fba example:
Code:

local sock=socket.tcp()

local finalStr = "Waiting string from HTTP request.."

i=1
table={}
table[0]="---"
end
-- connect to a webserver
sock:settimeout(5)

i="read"
if i=="read" then
     sock:connect("www.bogatyrstvo.ru", 80)
     sock:send("GET /rover.php HTTP/1.0\n")
     sock:send("Host: www.bogatyrstvo.ru\n\n")       
elseif i=="write" then
     sock:connect("www.bogatyrstvo.ru", 80)
     sock:send("POST /read.php?a=1234 HTTP/1.0\n")
     sock:send("Host: www.bogatyrstvo.ru\n\n")
else
     sock:connect("www.fbacreator.com", 80)       
     sock:send("GET /downloads/misc/tutorial_file.php HTTP/1.1\r\n")
     sock:send("Host: www.fbacreator.com\r\n\r\n")
end

local host,port = sock:getpeername()

function onmainloop()
        clear(50,50,50)       
        print(10,10,"YOU MUST BE CONNECTED TO INTERNET IN ORDER TO TEST THIS SAMPLE",0,0,255)
        print(10,30,"CONNECTED TO " .. host .. " ON PORT " .. port,0,255,0)

        for j=0,i do
        print(10,50+j*8,table[j],255,200,200)               
        end
       
        data,err = sock:receive()
        if data ~= nil then
                if data ~= finalStr then  --this put all server answers in the array "table" for the full view...
                        finalStr=data
                        i=i+1
                        table[i]=data
                        if err~=nil then table[i] = table[i].." ERROR: "..err end
                end
        end
end

function onstylusdown(x,y)
        quit()
end

function onquit()
        sock:close()
end

end


so... this is from wiki... about GET...

Quote:
Example session

Below is a sample conversation between an HTTP client and an HTTP server running on http://www.example.com, port 80.

Client request
Code:
 GET /index.html HTTP/1.1
 Host: www.example.com

A client request is followed by a blank line, so that request ends with a double newline, each in the form of a carriage return followed by a line feed. The "Host" header distinguishes between various DNS names sharing a single IP address, allowing name-based virtual hosting. While optional in HTTP/1.0, it is mandatory in HTTP/1.1.

Server response
Code:
 HTTP/1.1 200 OK
 Date: Mon, 23 May 2005 22:38:34 GMT
 Server: Apache/1.3.3.7 (Unix)  (Red-Hat/Linux)
 Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
 Etag: "3f80f-1b6-3e1cb03b"
 Accept-Ranges: bytes
 Content-Length: 438
 Connection: close
 Content-Type: text/html; charset=UTF-8

A server response is followed by a blank line and text of the requested page. The ETag (entity tag) header is used to determine if a cached version of the requested resource is identical to the current version of the resource on the server. Content-Type specifies the Internet media type of the data conveyed by the http message, while Content-Length indicates its length in bytes. The HTTP/1.1 webserver publishes its ability to respond to requests for certain byte ranges of the document by setting the header Accept-Ranges: bytes. This is useful if the client needs to have only certain portions[8] of a resource sent by the server, which is called byte serving. When Connection: close is sent in a header, it means that the web server will close the TCP connection immediately after the transfer of this package.


that's how client-server working... this is my GREATE rover.php :)
Code:
<?
print "wetrwet";
echo "апр123";
echo "апр123";
echo "123";
echo "123";
echo "12в3";
echo "1апр23";
echo "1в2аа3";
echo "123";
echo "1п23";
echo "1пр23";
echo "123";
echo "123";
?>
end
<>

The last two lines are important! :) my server didn't respond without it :)
and, finaly, "read.php"
Code:
<?
echo "yeeah! It's $a \n";
$file = fopen("data.txt","a");
  $str = "\n".$a;
  if (!$file)
  {
    echo( "file open's error" );
  }
  else
  {
    fputs ( $file, $str );
  }
  fclose ( $file );
?>

<>



this is my begin of super on-line game :) good luck everyone!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 12 posts ]  Go to page Previous 1 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited