[Gambas-user] Network article

Daniel Campos danielcampos at ...282...
Thu Oct 23 20:45:28 CEST 2003


Hi!

 Here's a little article which tries to explain the motivations
and structure on network component. 

 When I'll have some more time, I'll try to write a tutorial
about network component use, but by now I have to finish it! :)

Regards, 
 
-- 
Daniel Campos <danielcampos at ...282...>
-------------- next part --------------
Network and XML
---------------


  The future, al least for the next years, is based in networks and standards.
 Even big companies that always tried to hide all its internal file formats,
 have changed partially its mind, and now it seems they have discovered the
fire, talking about XML, SOAP, RPC, and things like this, that probably, could
be usual stuff today if they were put some effort and money on them in the past.


Think that...
-------------

  No one can imagine isolated devices today : you have to extract data from
them, know what's happening even if you are in the other side of the world.

 Devices are made by different manufacturers, and costumers think it's not their
matter to make them compatible. So, companies need standars to share information.

 Companies need to control its money, information is power and a chance to grow
and earn new money. Companies trust in the support of big hardware and software
companies.

So...
-------

 New back-office systems provided by main companies, are based on known standards,
mainly : data bases (SQL), http servers like Apache, XML, RPC and SOAP. If big
companies acts in that way, medium and small companies will do the same...or die.



XML, RPC and SOAP
-----------------

  When somebody is learning XML, the first idea is "what an stupid thing". Well,
XML seems to be only tags and random data you put in a file. And XML is really
that. The power of XML is that is an international standard, and that can be
easily used by people and computers. Lots of people can learn it, not just
programmers, create an implementation, write a XML document with a text editor,
and lot of libraries and other software will help them to share their documents,
or translate it to HTML or PDF beautiful reports.

  And HTTP is just a protocol, there are lots of them. Protocols are what languages
are for people, if two of more people know one language, they can share
information. But the birth of Arpanet and the grow of Internet made this
protocol quite popular: it is used to receive web pages, images, files,
commercial data and all the stuff you can imagine from servers that are placed
all around this world. So, almost all network hardware and software (routers,
firewalls, end-user computers, servers...) is ready to manage this protocol. Think
it twice: If you use HTTP to send and receive your information, you don't need to
worry about the physical ubication of your target : all the hardware in the hole
world, a big net of subnets, will carry the information without asking you any
question, just press the right button (well, usually the left button of mouse) ,
and let the big machine work.

 Here's where we find XML-RPC and SOAP. They are protocols to allow computers
to talk between them. Using this protocol, they can do more than sharing some
documents: one computer can send orders to other computer to perform some task,
and then the second computer will return the result of the action. You can find
this into your computer : some programs call to libraries and other programs
to perform its work. The only new thing in XML-RPC and SOAP, is that now,
conversations are not only into your computer, but between computers.
 But this is a big thing.  The idea is not new at all, but now, it is based on network and
data format standards: To carry the information HTTP, to write orders, questions
and answers, XML.   The end of this is that today, it is quite easy for programmers
and even for some users, to  write programs that will be connected with other
programs running in other computers, in different  parts of the world. And the
other important point, is that, you don't need to have a defined  hardware-software
platform, they are standards : you can both buy hardware and software from
many different providers. You can buy what you need : low price? high performance?
scalability?,  just look, compare, and buy or even use freely the best thing for you.

Gambas must be there
--------------------

 Gambas needs to implement standars, and I'd say more : Linux needs Gambas. Gambas
is a BASIC language interpreter. BASIC is an easy language, anybody can learn
a little, and start making little programs and scripts. A lot of programmers started
learning BASIC when they were children, may be on 8-bits CPUs. A lot of people
working in different sections of different companies, knows at least a little of
BASIC language. They are not programmers at all, but they have what they need as
they can write macros to help them on his work with little and medium data bases,
spread-sheets and text documents. They know how to create a formulary, write and
read data from tables, share some information sending it by mail... By other side,
there are tons of web depelopers, too busy to learn about pointers and memory
management, they have to write HTML, create beautiful pictures, administrate servers,
deal with hackers and many other things. They need a simple language to create
CGI's. There are things like PHP or Perl, but there's one called ASP which is not
more than BASIC mixed with HTML, so they know BASIC.

 So, the conclusion is that lots of people are waiting for BASIC to migrate to Linux.
What can we do here? We are in the middle of the road : we have a simple and well-designed
GUI (not very much projects can say that), we have the interpreter, and we have lots
of libraries written in C or C++ waiting to help us, may be the biggest API that any operating
system has ever known. To cross to the other side we need only to implement that standars
that will allow programmers and users to connect to the information they need.

 Network component is a piece in that target: Let's open the door that will give us the rest
of the world.


Network component
-----------------

 It is not really a component, it will be implemented in (al least) two components:
"networking" and "gbxml".

"Networking" is the base of all:

 Currently the web is based on TCP/IP protocols. We can say that the IP part of this
protocol is matter of operating system, we have to care about "TCP/" part. To implement
all stuff we have the following classes:

 *DnsClient : is a class to convert host names (like "gambas.sourceforge.net"), which
are understood by humans to IP addresses (like 192.168.0.1) which are the real
names for computers. It can perform its work using operating systems resources:
DNS, NIS, hosts file,NMB lookup, LDAP, etc...

 *ClientSocket : to share information with servers, we need to stablish a TCP connection.
This class can do that, and send and receive data in "raw" format.

 *ServerSocket : sometimes we'll be the servers, and we need to let clients connect
 with  us. This is the class to do it using TCP/IP.

 *Datagram and Datapacket : some internet tasks, like transfering multimedia streaming data,
do not work fine if they use a connection, so they usually use UDP, a more "primitive"
way of transfering data, with no flow control. Datagram class is intended to create
both UDP clients and servers.

 *UNIX sockets : sometimes we don't need to connect with other computers, but with
other programs in the same computer. Using TCP for this is not efficient, and you
waste a limited resource as TCP ports are. Unix sockets are local sockets implemented
by the operating system to "emulate" TCP sockets into the computer ( oh, well, this is not
a technical conference, I simply try to give an idea, you know? ), and data sharing
using this method is quite fast and inexpensive. Both ClientSocket and ServerSocket
can also stablish unix-socket connections.

(ServerSocket with Unix socket is not yet implemented)

 *HTTPClient : by using ClientSocket and ServerSocket you'll receive only raw data,
that you have to manage and verify. This client allows you to connect with HTTP servers
(like Apache, yes), managing all HTTP protocol, you have just to care about the
document (or object, as DOM people like to say) you receive.

(HTTPClient is not yet implemented)

 *SerialPort : Now let's speak about the rest of computing world. Not all
devices, specially designed for industrial or commerce tasks have an ethernet
connection. May be 70% of them have RS-232, RS-485, or RS-422 serial ports.
And programmers often have to stract or send information to them, and then compute
the information and convert it to data to be placed in a database, web pages,
and so on. So, there's also a class called "SerialPort" to allow send and receive
data using a serial port.

"GBXML" are the tools to connect with the world:

 (GBXML is not yet implemented)

* There will be at least two different pure-XML classes:

- A tree based class : it saves all XML information in memory, which makes
work with XML very easy, you can move to any part of the document, and modify
it easily, and using very few time.

- An XMLReader class, more conventional : it just reads pieces of XML document
from a file, without keeping it in memory. May be it is more slow, but when
you have a big document, a tree based model can use all your memory resources,
even hanging the computer.

- May be a SAX based XML class : it is useful to parse documents while you
are receiving it from a stream. (it is useful for other things, too)

* There will be XML-RPC client class : it will allow you to call remote RPC-servers
and receive data just as if you were calling methods from your own program, or at
least in a quite similar way. Nothing about TCP/IP or XML, just Integers, Strings,
Arrays...

* There must be also a XML-RPC server, for two reasons : the first, to "decrypt" incoming
information from client in XML format to data types, and second, to allow create
stand-alone servers without the need of "monsters" like Apache.

 In the future there will be work on SOAP front. The idea of SOAP is quite similar
to XML-RPC, it is also based on XML and HTTP, but with SOAP you can perform very complex
tasks, it is powerful, but by the other side is quite complex.






More information about the User mailing list