Whoops, posted from the wrong address, lets try again.. apologies to list
admin.
>
> ----- Original Message -----
> From: "Gollum" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, February 10, 2002 11:28 PM
> Subject: [hlcoders] Getting server info
>
>
> I'm writing an app that retrieves the master server list, then goes
> through
> the list and gets the server info. I can get the list just fine, but it
> seems that 90% of the servers return WSAECONNRESET. I've tried mucking
with
> the code in every way fathomable (with my limited socket knowledge
anyways),
> and have been unsuccessful at getting past this. Here's how I have set it
up
> now:
>
> --------------------------------------------
>
> // These here to ensure people know what the variables map to. The rest
> should be self-explanatory.
>
> #define BUF_SIZE 2048
> TIMEVAL    tv;
> fd_set    fd;

You should have a FD_ZERO(&fd) call here

> //Calls to set up the sockets omitted for brevity.

This code would be helpful.

> //Call sendto with a buffer that contains "details"
>
> memset(buffer, -1, sizeof(int));
> strncpy( (char*)&buffer[4], "details", 8);
> length = sendto(socket_desc, (char*)buffer, 12, 0, (struct sockaddr
> *)&host_sin, sizeof(host_sin) );
>
> //Checks to make sure length == the number bytes sent omitted.
> ...
> // Call select with a timeout value so the socket doesn't block on
> recvfrom().
>
> tv.tv_sec = 0;
> tv.tv_usec = 175000; // 175 milliseconds
>
> fd.fd_count = 1;
> fd.fd_array[0] = socket_desc;

This should be done with FD_SET(socket_desc, &fd);

> status = select(NULL, &fd, NULL, NULL, &tv);

You should probably have socket_desc+1 as your first parameter for
compatabilty

> // Checks to make sure the status says the socket is ready to receive
> omitted.

There should be a call to FD_ISSET(socket_desc, &fd);  here.

> ...
> // The socket is ready to have data retrieved from it.
>
> length = recvfrom(socket_desc, (char*)buffer, BUF_SIZE, 0, NULL, NULL);
>
> if (0 >= length )
> {
>     status = WSAGetLastError();
>     // boom... length returns SOCKET_ERROR and WSAGetLastError() returns
> WSAECONNRESET *way* too many freakin times here...
> }
>
> --------------------------------------------
>
> The thing that bugs me is that select() is saying the socket is ready, but
> when I call recv() I get WSAECONNRESET. Is this normal behavior? I've even
> tried adding code that will retry a server that returns WSAECONNRESET a
> number of times. My initial thinking behind doing that was maybe the
server
> reset the connection, so I should try to re-establish a connection and
ping
> it for the details again. No luck. Any ideas on a better way, or ideas why
> the recvfrom() call fails so many times would be great.

Try using the FD_xxx macros, it's much more sane.  Also, the details about
setting up the socket may be helpful, getting WSAECONNRESET leads me to
think you're using connections, whereas the functions you have used suggest
you are trying to use conntctionless.  I could be making a wrong assumption,
but perhaps the server is expecting it to be connectionless.

Hope this helps.

 Stu



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to