Board.KolibriOS.org
http://board.kolibrios.org/

CGI интерфейс и консольный ввод/вывод.
http://board.kolibrios.org/viewtopic.php?f=2&t=2197
Page 1 of 3

Author:  johnfound [ Thu Jan 17, 2013 9:46 am ]
Post subject:  CGI интерфейс и консольный ввод/вывод.

Начал думать насчет CGI интерфейс для phWeb сервер. И так как этот интерфейс работает через STDIN/STDOUT, то надо чтобы перенаправлять ввод/вывод к серверу. Насколько я знаю, консольные приложения в Колибри пользуют "console.obj". Перенаправлять нужно каждую программу независимо и одновременно - так как сервер может выполнять несколько скриптов одновременно.

Так, возможно ли реализовать это, чтобы было совместимо с console.obj или нельзя и надо делать своя спецификация?

Author:  XVilka [ Mon Feb 04, 2013 12:01 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

Может лучше сделать SCGI http://python.ca/scgi/protocol.txt ? Он намного более минималистичен, и рассчитан на скорость работы. И вместо STDIN/STDOUT лучше использовать "пайпы" в виде разделяемой памяти. Например, как этьо сделано здесь - viewtopic.php?f=48&t=1111&start=90#p40875

Author:  johnfound [ Mon Feb 04, 2013 1:08 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

SCGI будет, только он (как и FastCGI) задуман и в конечном счете подходит, только для большие приложения, которые очень нельзя выполнять в виде процессов - например PHP и Perl интерпретаторы и др.под. CGI скрипт, поддерживающий SCGI или FastCGI это по существу специализированны сервер, который работает все время и выполняет заявки от web сервера.

А насчет консолью, я посмотрю как это реализовано в существующем шэлле и постараюсь сделать чтобы было совместимо. Хотя и мне кажется, что пайпы должны поддерживаться в ядре.

Author:  hidnplayr [ Mon Feb 04, 2013 1:22 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

In Network branch kernel, it should already be possible to use a socket to communicate between different applications.
Use address family UNIX (1)

Author:  johnfound [ Mon Feb 04, 2013 1:31 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

hidnplayr wrote:
In Network branch kernel, it should already be possible to use a socket to communicate between different applications.
Use address family UNIX (1)


So, you suggest to use sockets for console input/output? It is probably not a bad idea, as long as the sockets are pipes actually. But how the started application will know the address/port of the "console server"? There can be any number of them working simultaneous.

Author:  hidnplayr [ Mon Feb 04, 2013 1:34 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

I just checked, they are not yet implemented as fully as i tought they were, sorry to have misled you.

Here is a brief description: http://en.wikipedia.org/wiki/Unix_domain_socket

I need to implement the socketpair function and finish some other code in sockets.inc before it can work.

Author:  hidnplayr [ Mon Feb 04, 2013 1:36 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

I do not really understand what 'console' window you are talking about, the text window on the server computer ?

Author:  johnfound [ Mon Feb 04, 2013 1:42 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

hidnplayr wrote:
I do not really understand what 'console' window you are talking about, the text window on the server computer ?


As "console", I mean the application which will accept console program output and send the console program input. It can be normal console window application that will output the received output to the screen and will send keystrokes to the console application, but it can be also web server that will send the output to the network and will send the requests to the CGI script (which is console application actually).

The console interface should be able to support all these variants in one consistent way.

Author:  hidnplayr [ Mon Feb 04, 2013 1:55 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

I believe a correct implementation would be to start an application with as argument the pointer to the console (Be it a socket, named buffer or something else)
If no arguments are passed, the applications should open a new console, preferably through console.obj (or it's newer variant)

The implementation of a real console system would greatly enhance the capabilities of kolibrios, go for it!

Author:  johnfound [ Mon Feb 04, 2013 2:32 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

If I understand correctly, this UNIX address family uses some kind of different addresses. Not IP/port pair. But what these addresses look like?

BTW: What are the plans about including the new network branch in the trunk?

Author:  hidnplayr [ Mon Feb 04, 2013 2:38 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

johnfound wrote:
If I understand correctly, this UNIX address family uses some kind of different addresses. Not IP/port pair. But what these addresses look like?

BTW: What are the plans about including the new network branch in the trunk?


You need no adressing, you call socketpair and it returns two socket pointers. The two sockets are already connected to eachother.
One is to be used by the local app (calling the function) and the other can be used by another app.

Then you can simply use send an receive :)

Author:  johnfound [ Mon Feb 04, 2013 2:57 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

hidnplayr wrote:
You need no adressing, you call socketpair and it returns two socket pointers. The two sockets are already connected to eachother.
One is to be used by the local app (calling the function) and the other can be used by another app.

Then you can simply use send an receive :)


Ah, I got it. So, I have to send 2 or 3 numbers to the child application - STDIN, STDOUT and STDERR, allocated by the parent application, right? Or maybe only two STDIO and STDERR...

It would be the best, if the transfer of these numbers was organized by the kernel - for example by using respective fields in the application header and passing these numbers directly to the fn.70.7
Now I have to pass them through the command line parameters, using ASCII string. :(

Author:  hidnplayr [ Mon Feb 04, 2013 3:02 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

One socket provides two-way communication so only two numbers are needed indeed.
You propose to create a new application header specific for console applications? I think it's a good idea.

Author:  johnfound [ Mon Feb 04, 2013 4:05 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

hidnplayr wrote:
One socket provides two-way communication so only two numbers are needed indeed.
You propose to create a new application header specific for console applications? I think it's a good idea.


Why only for console applications? To have several communication channels is good for any application. At least does not hurt. If the parent application does not want to use this mechanism it can simply pass NULL in these fields. The header version field could serve the purpose to indicate the presence of these fields.

The function 70.7 has two reserved fields with offsets $0c and $10 - they can be used for this purpose. This use will provide backward compatibility as well.

But it is serious changes, what other developers think about it?

Author:  johnfound [ Mon Feb 04, 2013 5:38 pm ]
Post subject:  Re: CGI интерфейс и консольный ввод/вывод.

Так, что думают ведущих разработчиков насчет таких перемен? Я может быть и возьмусь реализовать, только надо освоить SVN сначала. ;)

Page 1 of 3 All times are UTC+03:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/