void UDBSocket_close(UDBSocket socket) { switch (socket->type) { case UDBSocketStandardInOut: { ResetTermIOs(); break; } case UDBSocketUDPClient: case UDBSocketUDPServer: { closesocket(socket->fd); if (socket->UDP_host) free(socket->UDP_host); if (socket->serial_port) free(socket->serial_port); free(socket); break; } case UDBSocketSerial: { if (socket->hComms != 0) { CloseHandle(socket->hComms); socket->hComms = 0; } else { //ShowMessage("Comm port already closed"); } break; } default: break; } }
void UDBSocket_close(UDBSocket socket) { switch (socket->type) { case UDBSocketStandardInOut: { ResetTermIOs(); break; } case UDBSocketUDPClient: case UDBSocketUDPServer: { shutdown(socket->fd, SHUT_RDWR); close(socket->fd); if (socket->UDP_host) free(socket->UDP_host); if (socket->serial_port) free(socket->serial_port); free(socket); break; } case UDBSocketSerial: { close(socket->fd); if (socket->serial_port) free(socket->serial_port); free(socket); break; } default: break; } }