473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

using c with html interface

Hi,
I got the method of invoking a c executable code from the html.I tested
the invocation by writing a simple C
program that accepts two integers from the html page, multiplies them
and returns the result to the html page.
I have coded a program that uses sockets to communicate with the other
computer.
The OS used is Red Hat linux. When i call the executable file of this
program, the socket() function returns with an error. i.e the socket()
function call returns a negative value hence is unable to create
a socket.

However, when i execute the program on the command line in linux, the
program executes as expected and communicates with the other machine.

Please let me know as to how I can invoke the socket program using the
html interface.

Oct 14 '06 #1
6 3127

Vivek wrote:
Hi,
I got the method of invoking a c executable code from the html.I tested
the invocation by writing a simple C
program that accepts two integers from the html page, multiplies them
and returns the result to the html page.
You mean a CGI right? As far as I know Apache doesn't have SSI for C
programs.
I have coded a program that uses sockets to communicate with the other
computer.
The OS used is Red Hat linux. When i call the executable file of this
program, the socket() function returns with an error. i.e the socket()
function call returns a negative value hence is unable to create
a socket.
Off topic, but use perror() to give you a hint.

Tom

Oct 14 '06 #2

Tom St Denis wrote:
You mean a CGI right? As far as I know Apache doesn't have SSI for C
programs.
Off topic, but use perror() to give you a hint.

Tom
I can't relate how SSI will affect the invocation of the C-executable
which uses sockets for inter-machine. SSI just provides a handler which
will process files before they are sent to the client.
The c program will handle the socket communication whereas the html
will just provide the UI.

However, I haven't understood what happens internally(i.e within the
browser) when the executable file is invoked from the html.

The way c program is written is by including the following in any c
code.,
#include<stdlib.h>
printf("%s%c%c\n","Content-type: text/html;charset=iso-8859-1",13,10);
//The type is text/html

data = getenv("QUERY_STRING"); //QUERY_STRING contains the parameters
passed from the
//web page(eg;-
"m=12&n=10")
any subsequent printf() statements will print in the html page.

In the html the call is done as usual,
<form method="GET" action="/cgi-bin/test.cgi" test.cgi is the
executable file got by compiling
test.c

My issue is, when i do the same stuff in a c program which has socket
programming, the html
page appears but the socket() function call fails and returns a
negative value.

Oct 14 '06 #3
Ico
Vivek <ia********@gmail.comwrote:
>
My issue is, when i do the same stuff in a c program which has socket
programming, the html page appears but the socket() function call
fails and returns a negative value.
Like the previous poster said, use perror() or look at the value of the
errno variable to see while the socket() call failed.

--
:wq
^X^Cy^K^X^C^C^C^C
Oct 14 '06 #4
Vivek wrote:
Hi,
I got the method of invoking a c executable code from the html.I tested
the invocation by writing a simple C
program that accepts two integers from the html page, multiplies them
and returns the result to the html page.
I have coded a program that uses sockets to communicate with the other
computer.
Unless you're doing something like writing a
server, you should be communicating with a
running server through the CGI interface.
The OS used is Red Hat linux.
Then you probably already have the Apache
server on your machine, ready to fire up
after a bit of configuration. If not, you
install disk will have it.
Oct 14 '06 #5
"Vivek" <ia********@gmail.comwrites:
I got the method of invoking a c executable code from the html.I tested
the invocation by writing a simple C
program that accepts two integers from the html page, multiplies them
and returns the result to the html page.
I have coded a program that uses sockets to communicate with the other
computer.
The OS used is Red Hat linux.
This is off-topic. Standard C doesn't have any support for html or
sockets. Try a Linux-specific group, or comp.unix.programmer.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 14 '06 #6
Vivek wrote:
Hi,
I got the method of invoking a c executable code from the html.I tested
the invocation by writing a simple C
program that accepts two integers from the html page, multiplies them
and returns the result to the html page.
I have coded a program that uses sockets to communicate with the other
computer.
The OS used is Red Hat linux. When i call the executable file of this
program, the socket() function returns with an error. i.e the socket()
function call returns a negative value hence is unable to create
a socket.

However, when i execute the program on the command line in linux, the
program executes as expected and communicates with the other machine.

Please let me know as to how I can invoke the socket program using the
html interface.
This is off-topic (try comp.unix.programmer), but ... why are you trying
to establish a connection via a socket() with the client? Any output you
want should just be output to stdout, you don't need to establish a
socket connection to the peer.
Oct 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
6
by: Serious_Practitioner | last post by:
Good day all, and thank you in advance for your help. No - MANY thanks in advance for your help - I know nothing about using databases on Web servers. I am about to discuss a project with a...
0
by: Horia Tudosie | last post by:
Using Visual Studio 2003 This is to report a series of bugs regarding the FlagsAttribute and (independently) the usage of interfaces in Web applications. Let’s declare xColors type like: ...
0
by: Mark Goldin | last post by:
I am trying to put together a small project where I will learn how to embed win controls in apsx pages. So far I got some code. When I run an aspx page nothing is shown on the page. Here is a class...
2
by: DocAccolade | last post by:
I am trying to include a legacy com control (controlname.ocx) in an asp.net application using vs 2003. I have added the control to the user control tool box, then dragged it to the form. However,...
11
by: Craig Francis | last post by:
Ok I'm making a fairly simple application. It contains 2 web browsers, the top one is used so that you can view a website (i.e. one you have created). Every time you load a page, the HTML which...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
14
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm...
3
by: SMH | last post by:
Normally an SVG document is loaded/parsed/interpreted inside an HTML document using an 'object' (or 'embed') element, although there are supposedly other ways too. The problem is, the SVG document...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.