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; I don't know. I tried it before, but I did something wrong. Works now....

  1. #16
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I don't know. I tried it before, but I did something wrong. Works now.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  2. #17
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Why dont you just receive data with char recevied[1024] (for instance) and then just (in a loop):

    std::string recv_buff;
    recv_buff += received;

  3. #18
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    l2u, I like strings even less than vectors (don't ask why).

    Anyway, I have this vector:
    Code:
    std::vector<std::vector<char> > datar;
    It's basically like a vector of char arrays (actually char vectors).
    Now this should work (it should add a to the first subvector of datar):
    Code:
    datar[0].push_back('a');
    But windows throws an error "blabla has encountered an error and needs to close"...
    Everything I do with those subvectors gets me a that error...

    Actually I know a possible solution, but I don't understand why this doesn't work.
    I could make a temporary vector and when I'm finished with one of those I just insert it to the end of the main vector.
    Last edited by maxorator; 01-05-2007 at 10:46 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,801
    Does datar[0] even exist? Consider:
    Code:
    std::vector<std::vector<char> > datar(1); // create datar[0]
    datar[0].push_back('a');
    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

  5. #20
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I am sooo stupid. I think i was somehow expecting it to allocate memory automatically for that too. Thanks.
    Last edited by maxorator; 01-05-2007 at 11:11 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  6. #21
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630
    Quote Originally Posted by maxorator
    l2u, I like strings even less than vectors (don't ask why).
    Why would using vector be better in this case?
    Would it be faster?

Page 2 of 2 FirstFirst 12
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-17-2002, 11:16 PM
  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

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