473,412 Members | 2,003 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,412 software developers and data experts.

help with viewing web pages through a socket

i have created a webserver that listens to on port 7000 but when i connect to it via the browser http://localhost:7000 i dont get anything and the webserver stops

so can anyone help me here this is what i got so far

Expand|Select|Wrap|Line Numbers
  1.        open_ptr = open("/home/user/www/home.html",'r'); 
  2.  
  3.     while((n = read(open_ptr,buffer,256)) > 0)
  4.     {
  5.  
  6.     n = write( new_sock,buffer,256); 
  7.  
  8.     }
  9.  
  10.      close(open_ptr); 
  11.  
  12.      return 0; 
  13.      } 
  14.  
  15.  
  16.  
Mar 21 '11 #1
5 2053
Banfa
9,065 Expert Mod 8TB
What do you mean by you have create a web server?
You have written the code for one?
You have configured an already available web server? Which One?

Have you read the HTTP protocol?
What is the contents of /home/user/www/home.html?
Does if conform to a get or post request (or some other http request type)?
Mar 21 '11 #2
yeah i am trying to write a simple web server the contents oh home.html is just a simple html file with the title "home"

i havent used any get or post in my code, is there anything that can i can read up on which will help with my code ?
Mar 22 '11 #3
Banfa
9,065 Expert Mod 8TB
Are you writing a web-server because you want to write a web-server or because you need a web-server to create a web-site?

If its the latter case then I would just download and install Apache.

If you are writing a web-server for the programming experience the first thing you should do is familiarise yourself with http, Wikipedia is as good a place to start as any for that.
Mar 22 '11 #4
yeah its for my programming experience i created a socket i binded the socket to a port, then i listen on the socket then accept the connection but i am just stuck on how to send the the page to the browser ?
Mar 22 '11 #5
Banfa
9,065 Expert Mod 8TB
When you have excepted the connection the first thing to do is not send a page to the browser but wait for the browser to request a page, which it will do using HTTP, which is why I say read about and understand the basics of HTTP first.
Mar 23 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: b_prikls | last post by:
Hi all, i need your help, here is code, that makes http connection to a website throu a proxy server, and it works fine: ========================================== $proxy = "111.111.111.111";...
7
by: Martin | last post by:
I am a PHP newbie (just got my "Hello World" page working this morning). I'm doing some R&D work to see if PHP is viable for a situation I have. To accomplish what I want to do, I have to have the...
2
by: Éric GARANT | last post by:
Hello everyone, I can't open ASP documents with Windows 2000 Pro french version SP4 + IE6.0 SP1 + IIS 5.0. When I click an ASP file, it's FrontPage 2000 that opens it. If I choose Open With......
0
by: MaryO | last post by:
I have tried to bring up the data access page after creating my tables and forms. The only problem is that the information is not linking right. My dropdown boxes have nothing in them and one of...
0
by: Vince | last post by:
Hi, I wrote a windows service with a socket that receives files and once a file has been received it tries to execute it. My problem comes from execution because nothing happens. I have...
3
by: Winston Nimchan | last post by:
Hi: I would like to build a socket server application that is user configurable using XML (app.config) and would like some guidance. I already have a single socket server working but would...
3
by: steven.rojas | last post by:
I have a chat application based on PHP and Flash, I know that is necessary execute the socket server script from the console (#!/usr/ local/bin/php -q), but my problem is that I don't have SSH...
1
by: manaankit | last post by:
is it possible to immediately close the socket created widout letting it go into wait state n dan reuse dat port. plez tell me its urgent...
1
by: orehian | last post by:
Construct a one-time password system. · Write a server code and a client code. The server code takes as input a username and a one-time password from the client and then sends a message...
1
by: samuelsam | last post by:
My project must send data from server to client via socket which implement by tcp socket.Now it is working but there is a one big problem that when the server program end , I must run the server...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.