First of all. Thanks to all members of this comunity open source because is wonderfull the power of this lenguaje.
My level of knowledge is basic but I did some programs to modify text files.
Now I'd like send theses files or the data inside them by tcp from a computer to another. Windows xp and a local ethernet net with ip 192.168.0.2 and 192.168.0.3 for example.
I have started to learn the library chisock because I have readed that it's the simpliest way to comunicate.
I have problems to build a simple program that send information an other that receive it. I have compiled the following example in order to learn but it's imposible.
Code: Select all
#include "chisock.bi"
using chi
dim as socket sock
var socket_result = sock.client( "www.google.com", socket.socket.PORT.HTTP )
if( socket_result ) then print translate_error( socket_result )
sock.put_HTTP_request( "www.google.com/search?q=FreeBASIC" )
'' Good luck reading this - google uses no whitespace :)
print sock.get_until( "" )
sleep
connect_to_google.bas(7) error 89: No matching overloaded function, CLIENT() in 'var socket_result = sock.client( "www.google.com", socket.socket.PORT.HTTP )'
Build error(s)
I dont konw whats the problem.
By other side:
I suppose the steps for to build a prgram that sends information is:
Receiver
Create connection by TCP client.
Listening untiil it receive.
Close TCP client connection
Sender
Create connection by TCP server.
Send information.
Close TCP server connection.
Someone could write me a simply example sender program an other receiver program in order I learn how it works.
I have tried to implement the following function in order to connect to a webpage but I dont know how.
Code: Select all
#include "chisock.bi"
Using chi
'function client( byref server as string,ByVal port as integer ) as integer
'o Create a TCP client with the hostname "server" on the port "port"
Dim as chi.socket foo
if( foo.client( "www.google.com", 80 ) <> chi.SOCKET_OK ) then print "Error!": End If
if( foo.client( "www.google.com", 80 ) = chi.SOCKET_OK )Then Print foo.client( "www.google.com", 80 )
'* Returns "chi.SOCKET_OK" on success, else error.
'End Function
Sleep
I think it must be very easy to do a comunicaton using sockets o chisock but my low knowledge of functions, OOP, and librarys make me imposible to make a program that it works.
I supose the client program will be something simila to this:
Code: Select all
#include "chisock.bi"
Using chi
'function client( byref server as string,ByVal port as integer ) as integer
'o Create a TCP client with the hostname "server" on the port "port"
Dim as chi.socket foo
foo.client( "192.168.0.35",23)
Dim as string message
if( foo.get( message ) = TRUE ) Then print "I got: " & message:End if
I supose the server program will be something simila to this:
Code: Select all
#include "chisock.bi"
Using chi
'function client( byref server as string,ByVal port as integer ) as integer
'o Create a TCP client with the hostname "server" on the port "port"
Dim as chi.socket foo
foo.server(23)
'' I'm gonna give 'em a message!
Dim as string message = "Hello my fellow earthling!"
if( foo.put( message ) = FALSE ) Then Print "That didn't go over well. :("
For example it will be good a program that send data to the microsoft software "Hyperterminal" tha I have in my laptop.
Thanks in advance.
Javier.