31
Network / "Endless"-getting-messages problem
« on: May 25, 2011, 11:47:45 pm »
Hey,
so I have this connections I want to get from them always messages and just write them. The thing is that I'm talking about 20 TCP messages per second per client. And there gonna be a lot of clients.
Any way, I have a problem... With my 1 client connected, it's drops me an error in the 3rd message I send. My code is maybe weird, that's right - but that's how I thought. So every time the client sends something like:
3TR 1 name var1 var2\0
and I need the server to split the string every " " so I use string to vector split by boost. Here's my full code:
My problem:
What to do?
Thanks.
so I have this connections I want to get from them always messages and just write them. The thing is that I'm talking about 20 TCP messages per second per client. And there gonna be a lot of clients.
Any way, I have a problem... With my 1 client connected, it's drops me an error in the 3rd message I send. My code is maybe weird, that's right - but that's how I thought. So every time the client sends something like:
3TR 1 name var1 var2\0
and I need the server to split the string every " " so I use string to vector split by boost. Here's my full code:
Code: [Select]
while (CountinewWithPlayer)
{
std::size_t Receiveda = 0;
sf::Socket::Status status;
char MessageLivea[256];
status = (Client.Receive(MessageLivea, sizeof(MessageLivea), Receiveda));
if ( status == sf::Socket::Disconnected || status == sf::Socket::Error)
{
cout << "Disconnected" << connectedClients << endl;
CountinewWithPlayer = 0;
} else if ( status == sf::Socket::Done )
{
cout << MessageLivea << endl;
std::vector<std::string> current_stringLivea;
boost::split(current_stringLivea, MessageLivea, boost::is_any_of(" "));
cout << current_stringLivea[0] << current_stringLivea[1] << current_stringLivea[2] << current_stringLivea[3] << endl;
}
}
My problem:
Quote
Debug Assertion Failed!
Program: …
File: c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector
Line: 932
Expression: vector subscript out of range
For information on how your program can cause an assertion
Failure, see the Visual C++ documentation on asserts.
What to do?
Thanks.