Difference between revisions of "Networking/ru"

From Lazarus wiki
Jump to navigationJump to search
Line 133: Line 133:
 
</delphi>
 
</delphi>
  
== WebServices ==
+
== Веб-сервисы (WebServices) ==
  
 
According to the [http://www.w3.org/ W3C] a Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface that is described in a machine-processable format such as WSDL. Other systems interact with the Web service in a manner prescribed by its interface using messages, which may be enclosed in a SOAP envelope, or follow a REST approach. These messages are typically conveyed using HTTP, and are normally comprised of XML in conjunction with other Web-related standards. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Windows and Linux applications) is due to the use of open standards. OASIS and the W3C are the primary committees responsible for the architecture and standardization of web services. To improve interoperability between web service implementations, the WS-I organisation has been developing a series of profiles to further define the standards involved.
 
According to the [http://www.w3.org/ W3C] a Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface that is described in a machine-processable format such as WSDL. Other systems interact with the Web service in a manner prescribed by its interface using messages, which may be enclosed in a SOAP envelope, or follow a REST approach. These messages are typically conveyed using HTTP, and are normally comprised of XML in conjunction with other Web-related standards. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Windows and Linux applications) is due to the use of open standards. OASIS and the W3C are the primary committees responsible for the architecture and standardization of web services. To improve interoperability between web service implementations, the WS-I organisation has been developing a series of profiles to further define the standards involved.
 +
 +
Согласно [http://www.w3.org/ W3C] "веб-сервис" - это программная система, разработанная для поддержки взаимодействия комппьютер-компьютер по сети. Он имеет интерфейс, описанный в машинном формате как, например, [http://ru.wikipedia.org/wiki/WSDL WSDL]. Другие системы взаимодействуют веб-сервисом, способом, описанным их интерфейсом, используя сообщения, которые могут быть заключены в [http://ru.wikipedia.org/wiki/SOAP SOAP] упаковку или претворять собой [http://ru.wikipedia.org/wiki/REST REST] подход. Эти сообщения обычно передаются используя HTTP и являются содержимым XML в соединении с другим веб-стандартом. Программные приложения, написанные на разных языках программирования и запускаемые на разных платформах могут использовать веб-сервисы для обмена данными по компьютерным сетям, таким как интернет, методом, напоминающим меж-процессное(inter-process) взаимодействие внутри одного компьютера. Эта возможность компьютерного взаимодействия (например Windows и Linux приложений) обязана своим существованием использованию открытых стандартов. [http://ru.wikipedia.org/wiki/OASIS OASIS] и [http://ru.wikipedia.org/wiki/W3C W3C(wiki-ссылка)] - это главные комитеты, отвечающие за архитектуру и стандартизацию веб-сервисов. Для того, чтобы улучшать возможности взаимодействия между реализациями веб-сервисов, организация WS-I создает серии описаний для дальнейшего определения участвующих стандартов.
  
 
=== Web Service Toolkit for FPC & Lazarus ===
 
=== Web Service Toolkit for FPC & Lazarus ===

Revision as of 12:06, 27 March 2010

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) 한국어 (ko) polski (pl) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN)

This page will be the start for tutorials with regard to network programming with Lazarus. I am not an expert on networking programming and I will add to the article as I learn about it. I invite others to help create networking articles. Just add a link to the next section, add a page and create your own WiKi article. On this page some general information will be given.

Эта страница будет началом руководства по сетевому(network) програмированию в Lazarus. Я не эксперт в сетевом программировании и я буду добавлять статьи по мере моего изучения. Я приглашаю других помочь в создании статей по сетям. Просто добавьте ссылку на следующую секцию, добавьте страницу и создайте свою собственную WiKi-статью. На этой странице будет даваться общая информация.


Other networking tutorials

Протокол TCP/IP

Пример Webserver

Bellow there is an example http server written with Synapse and tested in Mac OS X, after changing the synapse source to use a fixed constant $20000 as MSG_NOSIGNAL, because this constant isn't present in the sockets unit in Mac OS X.

Ниже находится пример http-сервера, написанный в Synapse и оттестированный в Mac OS X, после изменения исходников synapse для использования константы $20000 как MSG_NOSIGNAL, потому что эта константа не существует в sockets unit в Mac OS X.

<delphi> {

 The Micro Pascal WebServer
 This is a very simple example webserver implemented with the Synapse library.
 It works with blocking sockets and a single thread, so it
 can only handle one request at a given time.
 It will write the headers that it receives from the browser
 to the standard output.
 It serves a fixed webpage for the / URI
 For any other URI it will return 504 not found

} program upserver;

{$ifdef fpc}

 {$mode delphi}

{$endif}

{$apptype console}

uses

 Classes, blcksock, sockets, Synautil, SysUtils;

{@@

 Attends a connection. Reads the headers and gives an
 appropriate response

} procedure AttendConnection(ASocket: TTCPBlockSocket); var

 timeout: integer;
 s: string;
 method, uri, protocol: string;
 OutputDataString: string;
 ResultCode: integer;

begin

 timeout := 120000;
 WriteLn('Received headers+document from browser:');
 //read request line
 s := ASocket.RecvString(timeout);
 WriteLn(s);
 method := fetch(s, ' ');
 uri := fetch(s, ' ');
 protocol := fetch(s, ' ');
 //read request headers
 repeat
   s := ASocket.RecvString(Timeout);
   WriteLn(s);
 until s = ;
 // Now write the document to the output stream
 if uri = '/' then
 begin
   // Write the output document to the stream
   OutputDataString :=
     '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'
     + ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + CRLF

+ '<html>

Teste

</html>' + CRLF;

   // Write the headers back to the client
   ASocket.SendString('HTTP/1.0 200' + CRLF);
   ASocket.SendString('Content-type: Text/Html' + CRLF);
   ASocket.SendString('Content-length: ' + IntTostr(Length(OutputDataString)) + CRLF);
   ASocket.SendString('Connection: close' + CRLF);
   ASocket.SendString('Date: ' + Rfc822DateTime(now) + CRLF);
   ASocket.SendString('Server: Servidor do Felipe usando Synapse' + CRLF);
   ASocket.SendString( + CRLF);
 //  if ASocket.lasterror <> 0 then HandleError;
   // Write the document back to the browser
   ASocket.SendString(OutputDataString);
 end
 else
   ASocket.SendString('HTTP/1.0 504' + CRLF);

end;

var

 ListenerSocket, ConnectionSocket: TTCPBlockSocket;

begin

 ListenerSocket := TTCPBlockSocket.Create;
 ConnectionSocket := TTCPBlockSocket.Create;
 ListenerSocket.CreateSocket;
 ListenerSocket.setLinger(true,10);
 ListenerSocket.bind('0.0.0.0','1500');
 ListenerSocket.listen;
 repeat
   if ListenerSocket.canread(1000) then
   begin
     ConnectionSocket.Socket := ListenerSocket.accept;
     WriteLn('Attending Connection. Error code (0=Success): ', ConnectionSocket.lasterror);
     AttendConnection(ConnectionSocket);
   end;
 until false;
 ListenerSocket.Free;
 ConnectionSocket.Free;

end. </delphi>

Веб-сервисы (WebServices)

According to the W3C a Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface that is described in a machine-processable format such as WSDL. Other systems interact with the Web service in a manner prescribed by its interface using messages, which may be enclosed in a SOAP envelope, or follow a REST approach. These messages are typically conveyed using HTTP, and are normally comprised of XML in conjunction with other Web-related standards. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., between Windows and Linux applications) is due to the use of open standards. OASIS and the W3C are the primary committees responsible for the architecture and standardization of web services. To improve interoperability between web service implementations, the WS-I organisation has been developing a series of profiles to further define the standards involved.

Согласно W3C "веб-сервис" - это программная система, разработанная для поддержки взаимодействия комппьютер-компьютер по сети. Он имеет интерфейс, описанный в машинном формате как, например, WSDL. Другие системы взаимодействуют веб-сервисом, способом, описанным их интерфейсом, используя сообщения, которые могут быть заключены в SOAP упаковку или претворять собой REST подход. Эти сообщения обычно передаются используя HTTP и являются содержимым XML в соединении с другим веб-стандартом. Программные приложения, написанные на разных языках программирования и запускаемые на разных платформах могут использовать веб-сервисы для обмена данными по компьютерным сетям, таким как интернет, методом, напоминающим меж-процессное(inter-process) взаимодействие внутри одного компьютера. Эта возможность компьютерного взаимодействия (например Windows и Linux приложений) обязана своим существованием использованию открытых стандартов. OASIS и W3C(wiki-ссылка) - это главные комитеты, отвечающие за архитектуру и стандартизацию веб-сервисов. Для того, чтобы улучшать возможности взаимодействия между реализациями веб-сервисов, организация WS-I создает серии описаний для дальнейшего определения участвующих стандартов.

Web Service Toolkit for FPC & Lazarus

Web Service Toolkit is a web services package for FPC and Lazarus.


XML Tutorial

External Links