0

I am newbie to network programming, trying to work & test a vnc server. i am using mingw and linking to LibVNCServer (DLL which i build locally) library

My main program compiles after liking to DLL and can run as listening server on port 5900, when i try to connect to this server either using telnet or vnc client programs i get "error in select: Result too large" repeated error from server console, this is coming from the following line

if (select(rfbScreen->maxFd+1, &listen_fds, NULL, NULL, NULL) == -1) {
      rfbLogPerror("rfbProcessNewConnection: error in select");
      return FALSE;
    }

Error number is errno=34, this can be matched from following mingw code piece http://wiki.rocrail.net/doku.php?id=win32-mingw-error&DokuWiki=mystpihv

Please see below for more bit code from file "sockets.c" of vncserver codebase

rfbBool rfbProcessNewConnection(rfbScreenInfoPtr rfbScreen)
{
    const int one = 1;
    int sock = -1;
#ifdef LIBVNCSERVER_IPv6
    struct sockaddr_storage addr;
#else
    struct sockaddr_in addr;
#endif
    socklen_t addrlen = sizeof(addr);
    fd_set listen_fds; 
    int chosen_listen_sock = -1;

    /* Do another select() call to find out which listen socket
       has an incoming connection pending. We know that at least 
       one of them has, so this should not block for too long! */
    FD_ZERO(&listen_fds);  
    if(rfbScreen->listenSock >= 0) 
      FD_SET(rfbScreen->listenSock, &listen_fds);
    if(rfbScreen->listen6Sock >= 0) 
      FD_SET(rfbScreen->listen6Sock, &listen_fds);
    if (select(rfbScreen->maxFd+1, &listen_fds, NULL, NULL, NULL) == -1) {
      rfbLogPerror("rfbProcessNewConnection: error in select");
      return FALSE;
    }
    if (FD_ISSET(rfbScreen->listenSock, &listen_fds)) 
      chosen_listen_sock = rfbScreen->listenSock;
    if (FD_ISSET(rfbScreen->listen6Sock, &listen_fds)) 
      chosen_listen_sock = rfbScreen->listen6Sock;

    if ((sock = accept(chosen_listen_sock,
               (struct sockaddr *)&addr, &addrlen)) < 0) {
      rfbLogPerror("rfbCheckFds: accept");
      return FALSE;
    }

    if(!rfbSetNonBlocking(sock)) {
      closesocket(sock);
      return FALSE;
    }

    if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
           (char *)&one, sizeof(one)) < 0) {
      rfbLogPerror("rfbCheckFds: setsockopt");
      closesocket(sock);
      return FALSE;
    }

#ifdef USE_LIBWRAP
    if(!hosts_ctl("vnc",STRING_UNKNOWN,inet_ntoa(addr.sin_addr),
          STRING_UNKNOWN)) {
      rfbLog("Rejected connection from client %s\n",
         inet_ntoa(addr.sin_addr));
      closesocket(sock);
      return FALSE;
    }
#endif

#ifdef LIBVNCSERVER_IPv6
    char host[1024];
    if(getnameinfo((struct sockaddr*)&addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST) != 0) {
      rfbLogPerror("rfbProcessNewConnection: error in getnameinfo");
    }
    rfbLog("Got connection from client %s\n", host);
#else
    rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr));
#endif

    rfbNewClient(rfbScreen,sock);

    return TRUE;
}

Do I also need Ws2_32.dlls in linker path?

EDIT

=== main.c ===

#include <iostream>
#include <stdio.h>
#include "rfb/rfb.h"

using namespace std;

int main(int argc, char** argv) {
    rfbScreenInfoPtr server = rfbGetScreen(&argc, argv, 400, 300, 8, 3, 4);
    server->frameBuffer = (char*)malloc(400 * 300 * 4);
    rfbInitServer(server);
    rfbRunEventLoop(server, -1, FALSE);
    return 0;
}
11
  • I suggest there is something wrong with the method that prints the error. Is it calling WSAGetLastError()?
    – user207421
    Jul 14, 2013 at 6:18
  • if you need details of error it translates to "Result too large" there is code strerror(errno) in rfbLogPerror() fn that gets it, full error string is "rfbProcessNewConnection: error in select: Result too large"
    – duckduckgo
    Jul 14, 2013 at 7:24
  • 1
    Exactly as I said. You are using Winsock, so 'errno' is the wrong thing to look at. See WSAGetLastError() as I suggested above.
    – user207421
    Jul 14, 2013 at 8:09
  • thank you, after i added WSAGetLastError() i get error code = 10038 which from here is WSAENOTSOCK code, where to go from here ?
    – duckduckgo
    Jul 14, 2013 at 9:43
  • 1
    No, I don't want to look at hundreds of lines of code, that's why I'm asking you to provide a minimal example that can be compiled on its own to reproduce the problem. Jul 14, 2013 at 10:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.