curl
 
免费且易于使用的客户端URL传输库,几乎支持所有协议。

网站:http://curl.haxx.se/libcurl/
支持平台:Win32,Linux,DOS
标题包括:卷曲
标题版本:7.24.0
示例:在examples / network / curl /

例子

''卷曲HTTP获取示例

#include once "curl.bi"
#include once "crt/string.bi"

''当接收到任何数据时,将调用此回调
Private Function write_callback cdecl _
    ( _
        ByVal buffer As Byte Ptr, _
        ByVal size As Integer, _
        ByVal nitems As Integer, _
        ByVal outstream As Any Ptr _
    ) As Integer

    Static As ZString Ptr zstr = 0
    Static As Integer maxbytes = 0

    Dim As Integer bytes = size * nitems

    ''当前的zstring缓冲区太小?
    If( maxbytes < bytes ) Then
        zstr = Reallocate( zstr, bytes + 1 )
        maxbytes = bytes
    End If

    ''“缓冲区”不是以空终止的,所以我们必须把它复制并添加null项
    memcpy( zstr, buffer, bytes )
    zstr[bytes] = 0

    ''只是打印它..
    Print *zstr

    Return bytes
End Function

    ''在里面
    Dim As CURL Ptr curl = curl_easy_init( )
    If( curl = 0 ) Then
        End 1
    End If

    ''设置url和回调
    curl_easy_setopt( curl, CURLOPT_URL, "freebasic.net" )
    curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, @write_callback )

    ''执行..
    curl_easy_perform( curl )

    ''关掉
    curl_easy_cleanup( curl )