Teen Programmers Unite  
 

 

Return to forum top

How to use CGI to call sockets??

Posted by Perl [send private reply] at January 29, 2003, 09:07:17 PM

Does anyone know how to use a cgi written in perl to call a socket that is written in perl too???
thanks!!

Posted by AnyoneEB [send private reply] at January 29, 2003, 10:03:15 PM

Your Perl CGI should be able to do everything a regular Perl script can do, so just call the socket how you normally would.

Posted by Perl [send private reply] at January 30, 2003, 01:28:58 AM

the problem is i dun know how to ??? have searching the net and books for the answer....
can give some example??? thanks!!!!

Posted by buzgub [send private reply] at January 30, 2003, 02:03:44 AM

http://www.linpro.no/lwp/

You can't "call a socket", but that link should help you with fetching a web page.

Posted by Psion [send private reply] at January 30, 2003, 09:13:09 AM

Honestly, you really aren't looking if you can't find this. You shouldn't need _examples_ if you know enough about Perl to be undertaking this project. You should go to a manual that lets you search for "sockets" and find the appropriate function documentation.

Posted by Perl [send private reply] at January 30, 2003, 09:34:50 PM

hi Psion..i'm really a newbie in perl but yet i have to undertake the perl project...no choice...

i had only less than one week to study perl and then proceed to the project..so i had to learn and ask while doing the project..anyway thanks for yr comments.

Posted by Perl [send private reply] at January 30, 2003, 09:55:46 PM

here is the case...

The client which is the web browser will call the CGI scripts, with some input variables, at the webserver.....the web server will retrieve information from the main server based on the input variables..which is unix based..

i need to create sockets on both web server and the main server so that they can communicate and pass information around...

the problem is how am i going to code the CGI scripts where it can call the socket..(i suppose)...and send the input variables to the socket locate at the main server and send the information back the webserver where the CGI scripts will generate the information out in HTML outputs???

anyone know...pls help!! i had started coding the CGI scipts but not yet implementing the codes to call the sockets(i suppose)..and i had created simple communication application ( i suppose it is socket) which can communicate...thank you!!

Posted by mop [send private reply] at January 31, 2003, 01:05:17 AM

so you will need to code a type of daemon for the main server which accepts requests from the webserver's perl program, and then sends back the appropriate information?

Maybe you can use an existing daemon, like having the webserver telnet (bad example, who cares) into the main one.

If you can install a perl program on the main server, why not just install apache on the main server and you'll be set?

Posted by CViper [send private reply] at January 31, 2003, 07:59:30 AM

I suppose the task is set up that way, so one can't really just install a web-server on the main server and get done with it. (the "main" sever might be behind a firewall or something)

I wouldn't suggest running an existing server-application: often it's alot more work to write an compatible client to something like telnet that roll your own. Especially if the only thing you're going to send is a few variables.

As psion already said, you really should check the doc's; using sockets is surely documented there.

Posted by Perl [send private reply] at February 01, 2003, 10:57:56 AM

REALLY thanks with all the replies!
hi mop! ya u r rite..need to set up communications between the web server and the main server!
i dun think can use telnet.

hi CViper! the web server and the main server r separated.


actually i'm a bit confused..

lets do it step by step.

first, i need to set up communication between the web server and the main server. How to do it?? by having one perl socket at the web server and the main server (both r separated servers)....am i rite?? i had to code the sockets myself!!

Posted by mop [send private reply] at February 01, 2003, 06:34:28 PM

If you are able to set up and write a perl program on the main server, what stops you from just setting up apache or what not on it?

I was using telnet as a bad example, but there could be other protocols. Though, as cviper said it will probably be a lot more efficient to write your own perl daemon to handle everything.

Although if there _is_ an existing and appropriate system you could look in to it because it would probably save a large amount of work.

Posted by CDR700 [send private reply] at February 03, 2003, 10:15:26 AM

Eternally people should be thankful for Compiled HTML (CHM) help systems. It is a really good thing, using the search tab sockets or IO can be found. It saves time.

Really people should download these before or straight after installing or running Perl/Pyhthon/PHP - they are avilible.

Just a tip for Perl.

Posted by Perl [send private reply] at February 04, 2003, 03:31:04 AM

THANKS for ALL the REPLIES!!

i think i'm really dumb..still could not understand...so i decided to ask again..

see this link first..
http://www.ictp.trieste.it/texi/perl/perl_53.html

if for example, i used this as my sockets..how am i going to code my CGI scripts to call or maybe use this socket??

i also quite confused if i'm rite or wrong..sad...

anyway after so long havnt told u guys..what i;m working as..
i'm currently on attachment....i'm still a student..

Posted by taubz [send private reply] at February 04, 2003, 08:21:54 AM

Perl, as has been said, this topic seems to be way above your level and you need someone to hold your hand through the whole process. If you're going to persue this, ask someone to help you by IM/email/IRC.

- taubz

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.