Mystery with receiving web sites through winsock

This is a discussion on Mystery with receiving web sites through winsock within the C++ Programming forums, part of the General Programming Boards category; There are some servers that don't send "Content-Length" line back. So I would need a buffer with "unlimited" size to ...

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    dynamically allocated array that grows as needed and loop of recv till the incoming buffer is empty?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    realloc in C or vector in C++?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    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?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    22,303
    Use &v[0]
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    22,303
    You are using a vector<char>?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    22,303
    Then you should probably use:
    Code:
    vector.insert(vector.end(), mychararray, mychararray + mychararray_size);
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Why not to pass it by ref?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Page 1 of 2 12 LastLast
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, 08:10 PM
  2. Determining Latency of Web Sites
    By mmondok in forum C Programming
    Replies: 4
    Last Post: 04-23-2003, 07: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, 09:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21