Newb Q: Server prog reqd to send files, how?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Newb Q: Server prog reqd to send files, how?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Newb Q: Server prog reqd to send files, how?  
Sal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-13-04 09:33 AM

Hi all,

Just hoping somone could point in the right direction. Have just started
learning to program sockets and have programmed both a client and server to
send and recieve messages, but now need to develop a web server to deliver a
web page. Obviously the server program would not have to change much, but to
send a file rather than a message, and I am using a browser as the client.
Any suggestions to what I should be looking at to enable the ability to grab
the file and deliver it??

TIA







[ Post a follow-up to this message ]



    Re: Newb Q: Server prog reqd to send files, how?  
GVK


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-13-04 11:33 AM

Sal wrote:
> Hi all,
>
> Just hoping somone could point in the right direction. Have just started
> learning to program sockets and have programmed both a client and server t
o
> send and recieve messages, but now need to develop a web server to deliver
 a
> web page. Obviously the server program would not have to change much, but 
to
> send a file rather than a message, and I am using a browser as the client.
> Any suggestions to what I should be looking at to enable the ability to gr
ab
> the file and deliver it??
>
> TIA
>
>
Hi,
You can use a while() loop to send a file - line by line. Something like

while(fgets(line,1024,fp) != NULL)
{
write(sockfd,line,strlen(line));
// anything else you want to do
}

I coded one such web server-client application in PERL. Hope the same works 
in C.

regards,
GVK

--
Happy Hacking!!!





[ Post a follow-up to this message ]



    Re: Newb Q: Server prog reqd to send files, how?  
GVK


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-13-04 11:33 AM

GVK wrote:
> Sal wrote:
> 
Forgot to add, see sendfile(2)

GVK
--
Happy Hacking!!!





[ Post a follow-up to this message ]



    Re: Newb Q: Server prog reqd to send files, how?  
Marc Rochkind


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-13-04 04:34 PM

"Sal" <sallas@dodo.com.au> wrote in message
news:4052ce82$0$22524$5a62ac22@freenews.iinet.net.au...
> Hi all,
>
> Just hoping somone could point in the right direction. Have just started
> learning to program sockets and have programmed both a client and server
to
> send and recieve messages, but now need to develop a web server to deliver
a
> web page. Obviously the server program would not have to change much, but
to
> send a file rather than a message, and I am using a browser as the client.
> Any suggestions to what I should be looking at to enable the ability to
grab
> the file and deliver it??
>
> TIA
>
>

By definition, a Web server implements the server side of HTTP, which is
specified by RFC ("Request for Comments") 2616, which you can read here:

http://www.w3.org/Protocols/rfc2616/rfc2616.html

There's a simple example of a Web server here:

http://basepath.com/aup/ex/group__AUP2ex.html

(Look in the examples for Chap. 8)

--
Marc Rochkind
"Advanced UNIX Programming" (publishing April 2004)
www.basepath.com/aup







[ Post a follow-up to this message ]



    Re: Newb Q: Server prog reqd to send files, how?  
sal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-04 03:33 AM


"Marc Rochkind" <rochkind@basepath.com> wrote in message
news:FZednRwPX-lasc7dRVn-iQ@speakeasy.net...
> "Sal" <sallas@dodo.com.au> wrote in message
> news:4052ce82$0$22524$5a62ac22@freenews.iinet.net.au... 
> to 
deliver
> a 
but
> to 
client. 
> grab 
>
> By definition, a Web server implements the server side of HTTP, which is
> specified by RFC ("Request for Comments") 2616, which you can read here:
>
> http://www.w3.org/Protocols/rfc2616/rfc2616.html
>
> There's a simple example of a Web server here:
>
> http://basepath.com/aup/ex/group__AUP2ex.html
>
> (Look in the examples for Chap. 8)
>
> --
> Marc Rochkind
> "Advanced UNIX Programming" (publishing April 2004)
> www.basepath.com/aup
>
>
Thanks all, what I really needed was to use:

file = fopen("homepage.html","r");
fread((void*)buffer,1,1023,file);
write(CS_sock,buffer,strlen(buffer));

(with other error code).







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:26 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register