MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / connect

Method connect

server/VGLTrans.cpp:407–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405
406
407void VGLTrans::connect(char *displayName, unsigned short port)
408{
409 char *serverName = NULL;
410
411 try
412 {
413 if(!displayName || strlen(displayName) <= 0)
414 THROW("Invalid receiver name");
415 char *ptr = NULL; serverName = strdup(displayName);
416 if((ptr = strrchr(serverName, ':')) != NULL)
417 {
418 // For backward compatibility with v2.0.x and earlier of the VirtualGL
419 // Client, we assume that anything after the final colon in the display
420 // string should be interpreted as a display number, if there are no
421 // other colons in the string or if the IP address is surrounded by
422 // square brackets. Otherwise, we assume that the colon is part of an
423 // IPv6 address.
424 if(strlen(ptr) > 1)
425 {
426 *ptr = '\0';
427 if(!strchr(serverName, ':') || (serverName[0] == '['
428 && serverName[strlen(serverName) - 1] == ']'))
429 {
430 dpynum = atoi(ptr + 1);
431 if(dpynum < 0 || dpynum > 65535) dpynum = 0;
432 }
433 else
434 {
435 free(serverName); serverName = strdup(displayName);
436 }
437 }
438 }
439 if(serverName[0] == '[' && serverName[strlen(serverName) - 1] == ']'
440 && strlen(serverName) > 2)
441 {
442 serverName[strlen(serverName) - 1] = '\0';
443 char *tmp = strdup(&serverName[1]);
444 free(serverName); serverName = tmp;
445 }
446 if(!strlen(serverName) || !strcmp(serverName, "unix"))
447 {
448 free(serverName); serverName = strdup("localhost");
449 }
450 socket = new Socket(true);
451 try
452 {
453 socket->connect(serverName, port);
454 }
455 catch(...)
456 {
457 vglout.println("[VGL] ERROR: Could not connect to VGL client. Make sure that vglclient is");
458 vglout.println("[VGL] running and that either the DISPLAY or VGL_CLIENT environment");
459 vglout.println("[VGL] variable points to the machine on which vglclient is running.");
460 throw;
461 }
462 thread = new Thread(this);
463 thread->start();
464 }

Callers 4

readbackMethod · 0.45
sendPluginMethod · 0.45
mainFunction · 0.45
RRTransConnectFunction · 0.45

Calls 2

printlnMethod · 0.80
startMethod · 0.45

Tested by 1

RRTransConnectFunction · 0.36