Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
-
cha0s
- Site Admin
- Posts: 5319
- Joined: May 27, 2005 6:42
- Location: USA
-
Contact:
Post
by cha0s »
Requires the latest chisock.
Code: Select all
#include "chisock/chisock.bi"
using chi
var our_post_variable = "A variable successfully transmitted via HTTP POST :)"
dim as socket my_socket
print "Opening socket..."
var socket_res = my_socket.client( "cha0s.selfip.org", 80 )
if( socket_res ) then print translate_error( socket_res )
print "Requesting file..."
my_socket.put_HTTP_request( "cha0s.selfip.org/fb_test.php", "POST", "post_val=" & our_post_variable )
print "Waiting for result from cha0s.selfip.org/fb_test.php..."
var html_result = my_socket.get_until( "" )
'' strip off the HTML headers
html_result = mid( html_result, instr( html_result, chr( 13, 10, 13, 10 ) ) + 4 )
print "Result: " & html_result
sleep
-
cha0s
- Site Admin
- Posts: 5319
- Joined: May 27, 2005 6:42
- Location: USA
-
Contact:
Post
by cha0s »
KristopherWindsor wrote:Where is the new version of Chisock? It doesn't work with the version I have. ;)
Where it always is; the projects forum.
-
zoomkat
- Posts: 15
- Joined: Apr 08, 2007 22:31
Post
by zoomkat »
I'm new to this and get a syntax error at "#pragma once" when I run the posted code. Is this something to do with chisock files?
-
cha0s
- Site Admin
- Posts: 5319
- Joined: May 27, 2005 6:42
- Location: USA
-
Contact:
Post
by cha0s »
zoomkat wrote:I'm new to this and get a syntax error at "#pragma once" when I run the posted code. Is this something to do with chisock files?
Yeah, chisock.bi uses that. You must have a pretty old version of FB. I don't support anything but the latest public release to compile chisock.
-
zoomkat
- Posts: 15
- Joined: Apr 08, 2007 22:31
Post
by zoomkat »
I've installed the latest version of FB for windows. I'm using FBIde version 0.4.6 to do a quick run of the code. I get the below error.
Compiler output:
C:\PROGRA~1\FREEBA~1\bin\win32\ld.exe: cannot find -lchisock
-
KristopherWindsor
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
-
Contact:
Post
by KristopherWindsor »
zoomkat wrote:I've installed the latest version of FB for windows. I'm using FBIde version 0.4.6 to do a quick run of the code. I get the below error.
Compiler output:
C:\PROGRA~1\FREEBA~1\bin\win32\ld.exe: cannot find -lchisock
You'll need to move the .a file out of the bin/win32 folder, or use:
#libpath "chisock/bin/win32"
:)
-
zoomkat
- Posts: 15
- Joined: Apr 08, 2007 22:31
Post
by zoomkat »
The code now works using full paths like below. Maybe a requirement when using FBIde?
#include "C:/Program Files/FreeBASIC/chisock/chisock.bi"
#libpath "C:/Program Files/FreeBASIC/chisock/bin/win32"
-
KristopherWindsor
- Posts: 2428
- Joined: Jul 19, 2006 19:17
- Location: Sunnyvale, CA
-
Contact:
Post
by KristopherWindsor »
zoomkat wrote:The code now works using full paths like below. Maybe a requirement when using FBIde?
#include "C:/Program Files/FreeBASIC/chisock/chisock.bi"
#libpath "C:/Program Files/FreeBASIC/chisock/bin/win32"
Oh, this is because you have chisock in the FreeBasic folder.
I had it in /[project folder]/chisock/
:)
-
cha0s
- Site Admin
- Posts: 5319
- Joined: May 27, 2005 6:42
- Location: USA
-
Contact:
Post
by cha0s »
Put the header and the lib in C:\Program Files\FreeBASIC\inc\chisock\chisock.bi and C:\Program Files\FreeBASIC\lib\win32\libchisock.a, respectively.
Then you don't have to use full paths, just #include "chisock/chisock.bi" and #inclib "chisock".
-
jimux
- Posts: 7
- Joined: Sep 07, 2008 21:55
Post
by jimux »
Forgive my ignorance as I have just loaded FreeBasic. Is this a Windows specific solution? I do not have chisock in the Linux standalone version.
-
jimux
- Posts: 7
- Joined: Sep 07, 2008 21:55
Post
by jimux »
Hello, chaOs.
great - Got that, Now all I have to do is find a way to port it to an embedded powerPC ST405.
many thanks for help.
-
Red
- Posts: 34
- Joined: Aug 06, 2007 15:56
-
Contact:
Post
by Red »