Oh. Battle.net's CHAT protocol hasn't changed in over a decade.
Printable View
Then the +11 thing should be fine :) I just thought I would give you "the talk" about skipping constants like that since if I don't someone else surely will.
Its good to know you are fundamentally having something like this occur.
And simply noticing "Gee, I don't really need that 'RESP: ' crap, do I? Plus it seems to always be the same. So I guess I can skip the first 6 characters."Code:RESP: 123456 xkpreston
RESP: 092342 ymaster5001
Same idea with the +11 thing.
Bonus question #2!
I need connect to timeout. I'm trying to convert what I already have to use non-blocking sockets and select(), but I'm failing. It claims to be connected, but it never actually logs on or receives data. Am I using select() correctly?
Edit1:Code:FD_ZERO(&sockets);
FD_SET(s, &sockets);
timeout.tv_sec = 0;
timeout.tv_usec = 100;
printf("Connecting...\n");
connect(s, (struct sockaddr*)&sin, sizeof(sin));
while (select(0, NULL, &sockets, NULL, &timeout) == SOCKET_ERROR) {
printf("[%d] ", WSAGetLastError());
printf("Retrying connection...\n");
connect(s, (struct sockaddr*)&sin, sizeof(sin));
FD_ZERO(&sockets);
FD_SET(s, &sockets);
}
And it works. However, if I set tv_usec to 999 and under, I get [10035] Retrying connection, [10037] Retrying connection, [10037] Retrying connection, [10037] Retrying connection, Connected!. Why is this? Do I have to close the socket and create a new, every time I retry the connection?Code:
FD_ZERO(&sockets);
FD_SET(s, &sockets);
timeout.tv_sec = 0;
timeout.tv_usec = 900;
printf("Connecting...\n");
connect(s, (struct sockaddr*)&sin, sizeof(sin));
ret = select(s+1, NULL, &sockets, NULL, &timeout);
while (ret == 0 || ret == SOCKET_ERROR) {
printf("[%d] ", WSAGetLastError());
printf("Retrying connection...\n");
connect(s, (struct sockaddr*)&sin, sizeof(sin));
FD_ZERO(&sockets);
FD_SET(s, &sockets);
ret = select(s+1, NULL, &sockets, NULL, &timeout);
}
Edit2: Durrrr. Microseconds.
Do I have to close the socket and create a new, every time I retry the connection?
MSVS comes with a program to tell you what these errors mean... But here you go
Quote:
Originally Posted by 10035
Sockets on windows can be such a piece of crap at times. This is so much easier to do on linux.Quote:
Originally Posted by 10037
So... I DO have to close the socket and create a new one if I want to stop a connection in progress and reconnect?
P.S. Thank you for being so patient with me. :)