Rev 2697 Rev 2933
Line 10... Line 10...
10 // 10 //
11 // 1.00 2012_09 Proof of concept (no configuration, not for public release) 11 // 1.00 2012_09 Proof of concept (no configuration, not for public release)
12 // 1.01 2012_09 Added parameter for device selection 12 // 1.01 2012_09 Added parameter for device selection
13 // 1.02 2012_12 Error handling and debugged 13 // 1.02 2012_12 Error handling and debugged
14 // 1.03 2012_12 Release version ready to publish 14 // 1.03 2012_12 Release version ready to publish
-   15 // 1.04 2013_04 Socket Bind Error with eplanation (multiple instance of XVC Server)
15 // 16 //
16 // 17 //
17 // Purpose: 18 // Purpose:
18 // 19 //
19 // XILINX development software (ISE, WebPack) supports several types of JTAG programming 20 // XILINX development software (ISE, WebPack) supports several types of JTAG programming
Line 77... Line 78...
77 // 78 //
78 // Possible improvements: 79 // Possible improvements:
79 // 80 //
80 // Linux version (Winsock library differs). 81 // Linux version (Winsock library differs).
81 // External definition of JTAG pins. 82 // External definition of JTAG pins.
-   83 // Enable Socket Number (to be able to run multiple XVC Servers), now it is constant XVC_TCP_PORT (should be only a default)
82   84  
83   85  
84 // Library Definitions 86 // Library Definitions
85 // ------------------- 87 // -------------------
86   88  
Line 463... Line 465...
463   465  
464 // Bind the SOCKED (assign the address) 466 // Bind the SOCKED (assign the address)
465 iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen); 467 iResult = bind(ListenSocket, result->ai_addr, (int)result->ai_addrlen);
466 if (iResult == SOCKET_ERROR) 468 if (iResult == SOCKET_ERROR)
467 { 469 {
-   470 int LastError=WSAGetLastError();
468 fprintf(stderr, "Bind failed with error: %d\n", WSAGetLastError()); 471 fprintf(stderr, "Bind failed with error: %d\n", LastError);
-   472 if (LastError==10048) fprintf(stderr, "Trying to start second instance of XVC Server?\n");
469 freeaddrinfo(result); 473 freeaddrinfo(result);
470 closesocket(ListenSocket); 474 closesocket(ListenSocket);
471 WSACleanup(); 475 WSACleanup();
472 jtagClosePort(); 476 jtagClosePort();
473 return -2; 477 return -2;
Line 485... Line 489...
485   489  
486 // Listen SOCKET 490 // Listen SOCKET
487 iResult = listen(ListenSocket, SOMAXCONN); 491 iResult = listen(ListenSocket, SOMAXCONN);
488 if (iResult == SOCKET_ERROR) 492 if (iResult == SOCKET_ERROR)
489 { 493 {
490 printf("listen failed with error: %d\n", WSAGetLastError()); 494 fprintf(stderr, "listen failed with error: %d\n", WSAGetLastError());
491 closesocket(ListenSocket); 495 closesocket(ListenSocket);
492 WSACleanup(); 496 WSACleanup();
493 jtagClosePort(); 497 jtagClosePort();
494 return -2; 498 return -2;
495 } 499 }
Line 505... Line 509...
505 sockaddr ClientSocetAddr; 509 sockaddr ClientSocetAddr;
506 int ClientSocetAddrLen = sizeof(sockaddr); 510 int ClientSocetAddrLen = sizeof(sockaddr);
507 ClientSocket = accept(ListenSocket, &ClientSocetAddr, &ClientSocetAddrLen); 511 ClientSocket = accept(ListenSocket, &ClientSocetAddr, &ClientSocetAddrLen);
508 if (ClientSocket == INVALID_SOCKET) 512 if (ClientSocket == INVALID_SOCKET)
509 { 513 {
510 printf("accept failed with error: %d\n", WSAGetLastError()); 514 fprintf(stderr, "accept failed with error: %d\n", WSAGetLastError());
511 closesocket(ListenSocket); 515 closesocket(ListenSocket);
512 WSACleanup(); 516 WSACleanup();
513 jtagClosePort(); 517 jtagClosePort();
514 return -2; 518 return -2;
515 } 519 }