SDLNet_TCP_JustShutdown


#1

I create a thread to run socket to receive message,but when I close the socket in main thread,in android and ios,SDLNet_TCP_Close is block。so please add functions below can solve this problem:

void SDLNet_TCP_JustShutdown(TCPsocket sock)
{
	if ( sock != NULL ) {
		if ( sock->channel != INVALID_SOCKET ) {
#ifdef _WIN32
		shutdown(sock->channel, 2);
#else
		shutdown(sock->channel, SHUT_RDWR);
#endif
		}
	}
}

void SDLNet_TCP_JustClose(TCPsocket sock)
{
    if ( sock != NULL ) {
	    if ( sock->channel != INVALID_SOCKET ) {
#ifdef _WIN32
		shutdown(sock->channel, 2);
#else
		shutdown(sock->channel, SHUT_RDWR);
#endif
        closesocket(sock->channel);
        sock->channel = INVALID_SOCKET;
        }
    }
}

void SDLNet_TCP_JustFree(TCPsocket sock)
{
    if ( sock != NULL ) {
        SDL_free(sock);
    }
}
void SDLNet_UDP_JustClose(UDPsocket sock)
{
    if ( sock != NULL ) {
		if ( sock->channel != INVALID_SOCKET ) {
#ifdef _WIN32
			shutdown(sock->channel, 2);
#else
			shutdown(sock->channel, SHUT_RDWR);
#endif
            closesocket(sock->channel);
            sock->channel = INVALID_SOCKET;
        }
    }
}

/* Just free a UDP network socket */
void SDLNet_UDP_JustFree(UDPsocket sock)
{
    if ( sock != NULL ) {
        SDL_free(sock);
    }
}

rejust tcp close function

void SDLNet_TCP_Close(TCPsocket sock)
{
    if ( sock != NULL ) {
        if ( sock->channel != INVALID_SOCKET ) {
#ifdef _WIN32
            shutdown(sock->channel, 2);
#else
	    shutdown(sock->channel, SHUT_RDWR);
#endif
            closesocket(sock->channel);
        }
        SDL_free(sock);
    }
}

#2

posted code becomes more readable if you put it in a code block, like

```c
void foo() {
  printf("asdf\n");
}
```

which would turn into

void foo() {
  printf("asdf\n");
}