Thread: Socket program doubt

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Socket program doubt

    Hi folks,

    I am a beginner in Socket Programming. I am trying to do some simple stuff but had a basic query.

    I would like to implement something similar to wget in C using TCP sockets (i.e., without using any HTTP libraries). Just give a URL (Example-- $wget www.foo.com/bar.pdf) through command line, construct a HTTP GET request to download the file identified by the URL, and download and save file.

    Right now trying this only for static HTTP content, but later want to modify for crawling entire site.

    Can someone point out how to begin? What are the steps involved?

    Thanks in advance.
    G

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    May I ask why you'd bother reinventing the wheel when there are options like libcurl out there?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well C won't do that without a lot of code on your part.

    To match your description of the work you want to do, you need something like cURL and libcurl

    If you really want to roll your own everything, then read "beej"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    2
    I just need to do it without using the HTTP libraries...

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    No problem - just read beej to figure out how to open a network connection.

    Then read this to figure out what it all means.
    Hypertext Transfer Protocol -- HTTP/1.1
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gtk Plug, Socket, embed one program into another.
    By arkashkin in forum Linux Programming
    Replies: 2
    Last Post: 03-27-2010, 01:01 AM
  2. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  3. Writing to an Output Socket in use by another program
    By maththeorylvr in forum Windows Programming
    Replies: 4
    Last Post: 10-28-2005, 12:17 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. my server program auto shut down
    By hanhao in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-13-2004, 10:49 PM