Thread: Mystery with receiving web sites through winsock

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Mystery with receiving web sites through winsock

    There are some servers that don't send "Content-Length" line back. So I would need a buffer with "unlimited" size to receive that. But the only thing that acts like an "unlimited" buffer is a file. But I don't want to save the data to a file. Maybe there's an easy solution...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    dynamically allocated array that grows as needed and loop of recv till the incoming buffer is empty?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    It is possible to increase a buffer's size when it's already allocated? How?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    realloc in C or vector in C++?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Hmm... I use "new" and "delete" and vector is totally another thing. Isn't there a way to do it that fits with "new" and "delete" or I'll have to use realloc?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    vector is just a wrapper for new and delete, it garantees that the allocated memory is continuos. so why do you need your own implementation of the same thing?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  7. #7
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Well, how do I get the pointer to the data after using a vector?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Use &v[0]
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Strange.
    Code:
    vector.push_back(mychararray);
    //invalid conversion from `char*' to `char'
    Code:
    vector.insert(vector.end(),mychararray);
    //invalid conversion from `char*' to `char'
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You are using a vector<char>?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Yes...
    Function definition:
    Code:
    int WebQuery(char* path,std::vector<char> welcome,char* postdata){
    somewhere in it:
    Code:
    welcome.insert(welcome.end(),p);
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Then you should probably use:
    Code:
    vector.insert(vector.end(), mychararray, mychararray + mychararray_size);
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #13
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I think it works now...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #14
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Code:
    	std::vector<char> data;
    	if(WebQuery("/index.php",data)==1){
    		MessageBox(0,&data[0],"wh",MB_OK);
    		SetWindowText(g.co[2][7],&data[0]);
    	}
    Before "return 1" in WebQuery, my vector contains everything I need, but the messagebox here shows that vector is empty... How do I pass the pointer to a vector?
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  15. #15
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Why not to pass it by ref?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. interact with web sites
    By awnjoor in forum C Programming
    Replies: 8
    Last Post: 07-26-2006, 07:10 PM
  2. Determining Latency of Web Sites
    By mmondok in forum C Programming
    Replies: 4
    Last Post: 04-23-2003, 06:47 AM
  3. Getting the ip address of web sites?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 03-18-2002, 12:16 AM
  4. Game Company Web Sites
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-17-2001, 08:32 PM