diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index a5e3374..0ace00d 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -252,7 +252,7 @@ static int getPrevTrack() void Editor_create() { int id; - Emgui_create("foo"); + Emgui_create(); id = Emgui_loadFontBitmap(g_minecraftiaFont, g_minecraftiaFontSize, EMGUI_LOCATION_MEMORY, 32, 128, g_minecraftiaFontLayout); RemoteConnection_createListner(); @@ -752,30 +752,13 @@ static int processCommands() case SET_ROW: { - int i = 0; + //int i = 0; ret = RemoteConnection_recv((char*)&newRow, sizeof(int), 0); - if (ret == -1) - { - // retry to get the data and do it for max of 20 times otherwise disconnect - - for (i = 0; i < 20; ++i) - { - if (RemoteConnection_recv((char*)&newRow, sizeof(int), 0) == 4) - { - viewInfo->rowPos = htonl(newRow); - viewInfo->selectStartRow = viewInfo->selectStopRow = viewInfo->rowPos; - - rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos); - return 1; - } - } - } - else + if (ret) { viewInfo->rowPos = htonl(newRow); viewInfo->selectStartRow = viewInfo->selectStopRow = viewInfo->rowPos; - rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos); } diff --git a/ogl_editor/src/RemoteConnection.c b/ogl_editor/src/RemoteConnection.c index aaa7167..11618ac 100644 --- a/ogl_editor/src/RemoteConnection.c +++ b/ogl_editor/src/RemoteConnection.c @@ -110,22 +110,6 @@ void RemoteConnection_mapTrackName(const char* name) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -static bool setBlocking(int sock, bool blocking) -{ - u_long block = blocking ? 0 : 1; -#if defined(_WIN32) - int error = ioctlsocket(sock, FIONBIO, &block); -#else - int error = ioctl(sock, FIONBIO, &block); -#endif - if (SOCKET_ERROR == error) - return false; - - return true; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool RemoteConnection_createListner() { struct sockaddr_in sin; @@ -164,8 +148,6 @@ bool RemoteConnection_createListner() while (listen(s_serverSocket, SOMAXCONN) == -1) ; - setBlocking(s_serverSocket, false); - rlog(R_INFO, "Created listner\n"); return true; @@ -213,14 +195,23 @@ static SOCKET clientConnect(SOCKET serverSocket, struct sockaddr_in* host) void RemoteConnection_updateListner(int currentRow) { - SOCKET clientSocket; + struct timeval timeout; struct sockaddr_in client; + SOCKET clientSocket = INVALID_SOCKET; + fd_set fds; + FD_ZERO(&fds); + FD_SET(s_serverSocket, &fds); + + timeout.tv_sec = 0; + timeout.tv_usec = 0; + if (RemoteConnection_connected()) return; // look for new clients + if (select(s_serverSocket + 1, &fds, NULL, NULL, &timeout) > 0) { clientSocket = clientConnect(s_serverSocket, &client); @@ -270,27 +261,11 @@ int RemoteConnection_recv(char* buffer, size_t length, int flags) ret = recv(s_socket, buffer, (int)length, flags); -#if defined(_WIN32) - if (ret <= 0) - { - int error = WSAGetLastError(); - if (error == WSAEWOULDBLOCK) - return -1; - } - - if (ret == 0) + if (ret != length) { RemoteConnection_disconnect(); return false; } -#else - if (ret == 0) - { - RemoteConnection_disconnect(); - return false; - } -#endif - return ret; }