- Timestamp:
- Oct 20, 1999, 12:03:55 PM (26 years ago)
- Location:
- trunk/src/wsock32
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/async.cpp
r1367 r1372 1 /* $Id: async.cpp,v 1. 1 1999-10-20 01:18:28phaller Exp $ */1 /* $Id: async.cpp,v 1.2 1999-10-20 10:03:52 phaller Exp $ */ 2 2 3 3 /* … … 23 23 #include <odinwrap.h> 24 24 #include <os2sel.h> 25 #include <os2win.h> 26 //#include <wsock32.h> 25 #define INCL_DOSERRORS 26 #define INCL_DOSSEMAPHORES 27 #include <os2.h> 28 29 #include <netdb.h> 30 #include <nerrno.h> 31 #include <sys/socket.h> 32 #include <wsock32const.h> 33 34 #include <process.h> 35 #include <string.h> 36 #include <stdlib.h> 37 27 38 #include <misc.h> 39 40 41 /***************************************************************************** 42 * Definitions * 43 *****************************************************************************/ 44 45 ODINDEBUGCHANNEL(WSOCK32-ASYNC) 46 28 47 29 48 … … 73 92 ULONG ul2; 74 93 ULONG ul3; 75 ULONG ul4;76 ULONG ul5;77 94 78 95 } ASYNCREQUEST, *PASYNCREQUEST; 79 96 80 97 98 /***************************************************************************** 99 * Prototypes * 100 *****************************************************************************/ 101 102 void _Optlink WorkerThreadProc(void* pParam); 103 BOOL _System PostMessageA(HWND hwnd, UINT ulMessage, WPARAM wParam, LPARAM lParam); 104 105 void _System SetLastError(int iError); 106 int _System GetLastError(void); 107 #define WSASetLastError(a) SetLastError(a) 108 81 109 82 110 /***************************************************************************** … … 86 114 class WSAAsyncWorker 87 115 { 88 // private members89 PASYNCREQUEST pRequestHead = NULL; // chain root90 PASYNCREQUEST pRequestTail = NULL; // chain root91 TID tidWorker = 0; // worker thread id92 HEV hevRequest; // fired upon new request93 HMUTEX hmtxRequestQueue; // request queue protection94 95 116 // public members 96 117 public: … … 98 119 ~WSAAsyncWorker(); // destructor 99 120 100 PASYNCREQUEST createRequest (HWND hwnd, 121 PASYNCREQUEST createRequest (ULONG ulType, 122 HWND hwnd, 101 123 ULONG ulMessage, 124 PVOID pBuffer, 125 ULONG ulBufferLength, 102 126 ULONG ul1 = 0, 103 127 ULONG ul2 = 0, 104 ULONG ul3 = 0, 105 ULONG ul4 = 0, 106 ULONG ul5 = 0); 128 ULONG ul3 = 0); 129 107 130 void pushRequest (PASYNCREQUEST pRequest); // put request on queue 108 131 BOOL deleteRequest (PASYNCREQUEST pRequest); // remove particular request 132 133 // the thread procedure 134 friend void _Optlink WorkerThreadProc(void* pParam); 109 135 110 136 111 137 // protected members 112 138 protected: 113 BOOL fTerminate = FALSE; // got to die ? 139 PASYNCREQUEST pRequestHead; // chain root 140 PASYNCREQUEST pRequestTail; // chain root 141 TID tidWorker; // worker thread id 142 HEV hevRequest; // fired upon new request 143 HMTX hmtxRequestQueue; // request queue protection 144 BOOL fTerminate; // got to die ? 114 145 115 146 TID startWorker (void); // start worker thread … … 117 148 int dispatchRequest(PASYNCREQUEST pRequest); // complete request 118 149 PASYNCREQUEST popRequest (void); // get one request from queue 119 BOOL deleteRequest (PASYNCREQUEST pRequest); // remove particular request120 150 121 151 void lockQueue (void); // enter mutex … … 132 162 133 163 164 /***************************************************************************** 165 * Local variables * 166 *****************************************************************************/ 167 168 static WSAAsyncWorker* wsaWorker = NULL; 169 170 171 /***************************************************************************** 172 * Name : 173 * Purpose : 174 * Parameters: 175 * Variables : 176 * Result : 177 * Remark : 178 * Status : UNTESTED STUB 179 * 180 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 181 *****************************************************************************/ 134 182 // constructor 135 183 WSAAsyncWorker::WSAAsyncWorker(void) 136 184 { 185 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::WSAAsyncWorker\n")); 186 187 pRequestHead = NULL; // chain root 188 pRequestTail = NULL; // chain root 189 tidWorker = 0; // worker thread id 190 fTerminate = FALSE; // got to die ? 191 137 192 startWorker(); 138 193 } 139 194 140 195 196 /***************************************************************************** 197 * Name : 198 * Purpose : 199 * Parameters: 200 * Variables : 201 * Result : 202 * Remark : 203 * Status : UNTESTED STUB 204 * 205 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 206 *****************************************************************************/ 141 207 // destructor 142 208 WSAAsyncWorker::~WSAAsyncWorker(void) 143 209 { 210 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::~WSAAsyncWorker (%08xh)\n", 211 this)); 212 144 213 // remove all requests 145 214 while (popRequest() != NULL); … … 158 227 159 228 229 /***************************************************************************** 230 * Name : 231 * Purpose : 232 * Parameters: 233 * Variables : 234 * Result : 235 * Remark : 236 * Status : UNTESTED STUB 237 * 238 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 239 *****************************************************************************/ 160 240 // start worker thread if necessary 161 241 TID WSAAsyncWorker::startWorker(void) 162 242 { 163 243 APIRET rc; 244 245 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::startWorker (%08xh)\n", 246 this)); 164 247 165 248 if (tidWorker == 0) … … 192 275 193 276 // create thread 277 #if defined(__IBMCPP__) 278 tidWorker = _beginthread(WorkerThreadProc, 279 (PVOID)this, 280 4096, 281 NULL); 282 #else 194 283 tidWorker = _beginthread(WorkerThreadProc, 195 284 (PVOID)this, 196 285 4096); 286 #endif 197 287 if (tidWorker == -1) 198 288 { … … 208 298 209 299 300 /***************************************************************************** 301 * Name : 302 * Purpose : 303 * Parameters: 304 * Variables : 305 * Result : 306 * Remark : 307 * Status : UNTESTED STUB 308 * 309 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 310 *****************************************************************************/ 210 311 // lock double-linked request chain 211 312 void WSAAsyncWorker::lockQueue(void) 212 313 { 213 DosRequestMutex(hmtxRequestQueue, SEM_INDEFINITE_WAIT); 214 } 215 216 314 DosRequestMutexSem(hmtxRequestQueue, SEM_INDEFINITE_WAIT); 315 } 316 317 318 /***************************************************************************** 319 * Name : 320 * Purpose : 321 * Parameters: 322 * Variables : 323 * Result : 324 * Remark : 325 * Status : UNTESTED STUB 326 * 327 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 328 *****************************************************************************/ 217 329 // unlock double-linked request chain 218 330 void WSAAsyncWorker::unlockQueue(void) 219 331 { 220 DosReleaseMutex(hmtxRequestQueue); 221 } 222 223 332 DosReleaseMutexSem(hmtxRequestQueue); 333 } 334 335 336 /***************************************************************************** 337 * Name : 338 * Purpose : 339 * Parameters: 340 * Variables : 341 * Result : 342 * Remark : 343 * Status : UNTESTED STUB 344 * 345 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 346 *****************************************************************************/ 224 347 // get request from queue 225 348 PASYNCREQUEST WSAAsyncWorker::popRequest(void) … … 245 368 246 369 370 /***************************************************************************** 371 * Name : 372 * Purpose : 373 * Parameters: 374 * Variables : 375 * Result : 376 * Remark : 377 * Status : UNTESTED STUB 378 * 379 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 380 *****************************************************************************/ 247 381 // insert request into queue 248 382 void WSAAsyncWorker::pushRequest(PASYNCREQUEST pNew) … … 275 409 276 410 411 /***************************************************************************** 412 * Name : 413 * Purpose : 414 * Parameters: 415 * Variables : 416 * Result : 417 * Remark : 418 * Status : UNTESTED STUB 419 * 420 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 421 *****************************************************************************/ 277 422 // delete particular request from queue 278 423 BOOL WSAAsyncWorker::deleteRequest(PASYNCREQUEST pDelete) … … 321 466 } 322 467 468 delete pDelete; // free the memory 323 469 bResult = TRUE; // OK 324 470 } … … 329 475 330 476 477 /***************************************************************************** 478 * Name : 479 * Purpose : 480 * Parameters: 481 * Variables : 482 * Result : 483 * Remark : 484 * Status : UNTESTED STUB 485 * 486 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 487 *****************************************************************************/ 488 489 PASYNCREQUEST WSAAsyncWorker::createRequest (ULONG ulType, 490 HWND hwnd, 491 ULONG ulMessage, 492 PVOID pBuffer, 493 ULONG ulBufferLength, 494 ULONG ul1, 495 ULONG ul2, 496 ULONG ul3) 497 { 498 PASYNCREQUEST pNew = new ASYNCREQUEST(); 499 500 // fill the structure 501 pNew->pPrev = NULL; 502 pNew->pNext = NULL; 503 pNew->ulType = ulType; 504 pNew->ulState = RS_WAITING; 505 pNew->hwnd = hwnd; 506 pNew->ulMessage = ulMessage; 507 pNew->pBuffer = pBuffer; 508 pNew->ulBufferLength = ulBufferLength; 509 pNew->ul1 = ul1; 510 pNew->ul2 = ul2; 511 pNew->ul3 = ul3; 512 513 return pNew; 514 } 515 516 517 /***************************************************************************** 518 * Name : 519 * Purpose : 520 * Parameters: 521 * Variables : 522 * Result : 523 * Remark : 524 * Status : UNTESTED STUB 525 * 526 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 527 *****************************************************************************/ 331 528 332 529 void WSAAsyncWorker::asyncGetHostByAddr (PASYNCREQUEST pRequest) … … 338 535 USHORT rc; 339 536 537 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByAddr (%08xh, %08xh)\n", 538 this, 539 pRequest)); 540 340 541 // result buffer length 341 542 usLength = min(pRequest->ulBufferLength, sizeof(struct hostent)); 342 543 343 544 // call API 344 pHostent = gethostbyaddr((const char*)pRequest->u 1,345 (int) pRequest->u 2,346 (int) pRequest->u 3);545 pHostent = gethostbyaddr((const char*)pRequest->ul1, 546 (int) pRequest->ul2, 547 (int) pRequest->ul3); 347 548 if (pHostent == NULL) // error ? 348 549 { … … 368 569 } 369 570 571 572 /***************************************************************************** 573 * Name : 574 * Purpose : 575 * Parameters: 576 * Variables : 577 * Result : 578 * Remark : 579 * Status : UNTESTED STUB 580 * 581 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 582 *****************************************************************************/ 583 370 584 void WSAAsyncWorker::asyncGetHostByName (PASYNCREQUEST pRequest) 371 585 { … … 376 590 USHORT rc; 377 591 592 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByName (%08xh, %08xh)\n", 593 this, 594 pRequest)); 595 378 596 // result buffer length 379 597 usLength = min(pRequest->ulBufferLength, sizeof(struct hostent)); 380 598 381 599 // call API 382 pHostent = gethostbyname((const char*)pRequest->u 1);600 pHostent = gethostbyname((const char*)pRequest->ul1); 383 601 if (pHostent == NULL) // error ? 384 602 { … … 405 623 406 624 625 /***************************************************************************** 626 * Name : 627 * Purpose : 628 * Parameters: 629 * Variables : 630 * Result : 631 * Remark : 632 * Status : UNTESTED STUB 633 * 634 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 635 *****************************************************************************/ 636 407 637 void WSAAsyncWorker::asyncGetProtoByName (PASYNCREQUEST pRequest) 408 638 { … … 413 643 USHORT rc; 414 644 645 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByName (%08xh, %08xh)\n", 646 this, 647 pRequest)); 648 415 649 // result buffer length 416 650 usLength = min(pRequest->ulBufferLength, sizeof(struct protoent)); 417 651 418 652 // call API 419 pProtoent = getprotobyname((const char*)pRequest->u 1);653 pProtoent = getprotobyname((const char*)pRequest->ul1); 420 654 if (pProtoent == NULL) // error ? 421 655 { … … 441 675 } 442 676 677 678 /***************************************************************************** 679 * Name : 680 * Purpose : 681 * Parameters: 682 * Variables : 683 * Result : 684 * Remark : 685 * Status : UNTESTED STUB 686 * 687 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 688 *****************************************************************************/ 689 443 690 void WSAAsyncWorker::asyncGetProtoByNumber(PASYNCREQUEST pRequest) 444 691 { … … 449 696 USHORT rc; 450 697 698 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByNumber (%08xh, %08xh)\n", 699 this, 700 pRequest)); 701 451 702 // result buffer length 452 703 usLength = min(pRequest->ulBufferLength, sizeof(struct protoent)); 453 704 454 705 // call API 455 pProtoent = getprotobyname(( int)pRequest->u1);706 pProtoent = getprotobyname((const char*)pRequest->ul1); 456 707 if (pProtoent == NULL) // error ? 457 708 { … … 478 729 479 730 731 /***************************************************************************** 732 * Name : 733 * Purpose : 734 * Parameters: 735 * Variables : 736 * Result : 737 * Remark : 738 * Status : UNTESTED STUB 739 * 740 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 741 *****************************************************************************/ 742 480 743 void WSAAsyncWorker::asyncGetServByName(PASYNCREQUEST pRequest) 481 744 { … … 486 749 USHORT rc; 487 750 751 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByName (%08xh, %08xh)\n", 752 this, 753 pRequest)); 754 488 755 // result buffer length 489 756 usLength = min(pRequest->ulBufferLength, sizeof(struct servent)); 490 757 491 758 // call API 492 pServent = getservbyname((const char*)pRequest->u 1,493 (const char*)pRequest->u 2);759 pServent = getservbyname((const char*)pRequest->ul1, 760 (const char*)pRequest->ul2); 494 761 if (pServent == NULL) // error ? 495 762 { … … 516 783 517 784 785 /***************************************************************************** 786 * Name : 787 * Purpose : 788 * Parameters: 789 * Variables : 790 * Result : 791 * Remark : 792 * Status : UNTESTED STUB 793 * 794 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 795 *****************************************************************************/ 796 518 797 void WSAAsyncWorker::asyncGetServByPort(PASYNCREQUEST pRequest) 519 798 { … … 524 803 USHORT rc; 525 804 805 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByPort (%08xh, %08xh)\n", 806 this, 807 pRequest)); 808 526 809 // result buffer length 527 810 usLength = min(pRequest->ulBufferLength, sizeof(struct servent)); 528 811 529 812 // call API 530 pServent = getservbyport((int )pRequest->u 1,531 (const char*)pRequest->u 2);813 pServent = getservbyport((int )pRequest->ul1, 814 (const char*)pRequest->ul2); 532 815 if (pServent == NULL) // error ? 533 816 { … … 554 837 555 838 839 /***************************************************************************** 840 * Name : 841 * Purpose : 842 * Parameters: 843 * Variables : 844 * Result : 845 * Remark : 846 * Status : UNTESTED STUB 847 * 848 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 849 *****************************************************************************/ 556 850 // process one request 557 851 int WSAAsyncWorker::dispatchRequest(PASYNCREQUEST pRequest) 558 852 { 853 dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::dispatchRequest (%08xh, %08xh)\n", 854 this, 855 pRequest)); 856 559 857 // check request state first 560 858 switch(pRequest->ulState) … … 574 872 575 873 // OK, servicing request 576 pRequest->ulStat us= RS_BUSY;874 pRequest->ulState = RS_BUSY; 577 875 578 876 switch(pRequest->ulType) … … 582 880 return 1; 583 881 584 case WSAASYNC_GETHOSTBYADDR: 585 asyncGetHostByAddr(pRequest->hwnd, 586 pRequest->ulMessage, 587 (char*)pRequest->u1, 588 (int) pRequest->u2, 589 (int) pRequest->u3, 590 (char*)pRequest->u4, 591 (int) pRequest->u5); 592 return 1; 593 594 case WSAASYNC_GETHOSTBYNAME: 595 asyncGetHostByName(pRequest->hwnd, 596 pRequest->ulMessage, 597 (char*)pRequest->u1, 598 (char*)pRequest->u2, 599 (int) pRequest->u3); 600 break; 601 602 case WSAASYNC_GETPROTOBYNAME: 603 asyncGetProtoByName (pRequest->hwnd, 604 pRequest->ulMessage, 605 (char*)pRequest->u1, 606 (char*)pRequest->u2, 607 (int) pRequest->u3); 608 break; 609 610 case WSAASYNC_GETPROTOBYNUMBER: 611 asyncGetProtoByNumber(pRequest->hwnd, 612 pRequest->ulMessage, 613 (int) pRequest->u1, 614 (char*)pRequest->u2, 615 (int) pRequest->u3); 616 break; 617 618 case WSAASYNC_GETSERVBYNAME: 619 asyncGetServByName (pRequest->hwnd, 620 pRequest->ulMessage, 621 (char*)pRequest->u1, 622 (char*)pRequest->u2, 623 (char*)pRequest->u3, 624 (int) pRequest->u4); 625 break; 626 627 case WSAASYNC_GETSERVBYPORT: 628 asyncGetServByPort (pRequest->hwnd, 629 pRequest->ulMessage, 630 (int) pRequest->u1, 631 (char*)pRequest->u2, 632 (char*)pRequest->u3, 633 (int) pRequest->u4); 634 break; 635 636 case WSAASYNC_SELECT: 637 break; 882 case WSAASYNC_GETHOSTBYADDR: asyncGetHostByAddr (pRequest); return 1; 883 case WSAASYNC_GETHOSTBYNAME: asyncGetHostByName (pRequest); return 1; 884 case WSAASYNC_GETPROTOBYNAME: asyncGetProtoByName (pRequest); return 1; 885 case WSAASYNC_GETPROTOBYNUMBER: asyncGetProtoByNumber(pRequest); return 1; 886 case WSAASYNC_GETSERVBYNAME: asyncGetServByName (pRequest); return 1; 887 case WSAASYNC_GETSERVBYPORT: asyncGetServByPort (pRequest); return 1; 888 889 // case WSAASYNC_SELECT: 890 // break; 638 891 639 892 default: … … 643 896 } 644 897 645 pRequest->ulStat us= RS_DONE;898 pRequest->ulState = RS_DONE; 646 899 return 0; 647 900 } 648 901 649 902 903 /***************************************************************************** 904 * Name : 905 * Purpose : 906 * Parameters: 907 * Variables : 908 * Result : 909 * Remark : 910 * Status : UNTESTED STUB 911 * 912 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 913 *****************************************************************************/ 650 914 // process all requests in queue until termination 651 915 void WSAAsyncWorker::processingLoop(void) … … 662 926 pRequest = popRequest(); // get request from queue 663 927 if (pRequest != NULL) 928 { 664 929 dispatchRequest(pRequest); // process request 930 delete pRequest; // free the memory 931 } 665 932 } 666 while (pRequest != NULL) 933 while (pRequest != NULL); 667 934 668 935 // wait for semaphore … … 676 943 677 944 945 /***************************************************************************** 946 * Name : 947 * Purpose : 948 * Parameters: 949 * Variables : 950 * Result : 951 * Remark : 952 * Status : UNTESTED STUB 953 * 954 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 955 *****************************************************************************/ 678 956 // thread procedure 679 void _ System WorkerThreadProc(PVOIDpParam)957 void _Optlink WorkerThreadProc(void* pParam) 680 958 { 681 959 // convert object pointer … … 685 963 686 964 965 /***************************************************************************** 966 * Name : 967 * Purpose : 968 * Parameters: 969 * Variables : 970 * Result : 971 * Remark : 972 * Status : UNTESTED STUB 973 * 974 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 975 *****************************************************************************/ 687 976 // the real function calls 688 977 ODINFUNCTION5(HANDLE, WSAAsyncGetHostByName, HWND, hwnd, … … 692 981 int, buflen) 693 982 { 694 PASYNCREQUEST pRequest = wsaWorker->createRequest((HWND) hwnd, 983 dprintf(("name = %s\n", name)); 984 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETHOSTBYNAME, 985 (HWND) hwnd, 986 (ULONG)wMsg, 695 987 (PVOID)buf, 696 988 (ULONG)buflen, 697 (ULONG)wMsg,698 989 (ULONG)name); 699 990 wsaWorker->pushRequest(pRequest); … … 702 993 703 994 995 /***************************************************************************** 996 * Name : 997 * Purpose : 998 * Parameters: 999 * Variables : 1000 * Result : 1001 * Remark : 1002 * Status : UNTESTED STUB 1003 * 1004 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1005 *****************************************************************************/ 1006 // the real function calls 1007 ODINFUNCTION7(HANDLE, WSAAsyncGetHostByAddr, HWND, hwnd, 1008 unsigned int, wMsg, 1009 const char*, addr, 1010 int, len, 1011 int, type, 1012 char*, buf, 1013 int, buflen) 1014 { 1015 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETHOSTBYADDR, 1016 (HWND) hwnd, 1017 (ULONG)wMsg, 1018 (PVOID)buf, 1019 (ULONG)buflen, 1020 (ULONG)addr, 1021 (ULONG)len, 1022 (ULONG)type); 1023 wsaWorker->pushRequest(pRequest); 1024 return (HANDLE)pRequest; 1025 } 1026 1027 1028 /***************************************************************************** 1029 * Name : 1030 * Purpose : 1031 * Parameters: 1032 * Variables : 1033 * Result : 1034 * Remark : 1035 * Status : UNTESTED STUB 1036 * 1037 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1038 *****************************************************************************/ 1039 // the real function calls 1040 ODINFUNCTION6(HANDLE, WSAAsyncGetServByName, HWND, hwnd, 1041 unsigned int, wMsg, 1042 const char*, name, 1043 const char*, proto, 1044 char*, buf, 1045 int, buflen) 1046 { 1047 dprintf(("name = %s, proto = %s\n", name, proto)); 1048 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETSERVBYNAME, 1049 (HWND) hwnd, 1050 (ULONG)wMsg, 1051 (PVOID)buf, 1052 (ULONG)buflen, 1053 (ULONG)name, 1054 (ULONG)proto); 1055 wsaWorker->pushRequest(pRequest); 1056 return (HANDLE)pRequest; 1057 } 1058 1059 1060 /***************************************************************************** 1061 * Name : 1062 * Purpose : 1063 * Parameters: 1064 * Variables : 1065 * Result : 1066 * Remark : 1067 * Status : UNTESTED STUB 1068 * 1069 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1070 *****************************************************************************/ 1071 // the real function calls 1072 ODINFUNCTION6(HANDLE, WSAAsyncGetServByPort, HWND, hwnd, 1073 unsigned int, wMsg, 1074 int, port, 1075 const char*, proto, 1076 char*, buf, 1077 int, buflen) 1078 { 1079 dprintf(("proto = %s\n", proto)); 1080 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETSERVBYPORT, 1081 (HWND) hwnd, 1082 (ULONG)wMsg, 1083 (PVOID)buf, 1084 (ULONG)buflen, 1085 (ULONG)port, 1086 (ULONG)proto); 1087 wsaWorker->pushRequest(pRequest); 1088 return (HANDLE)pRequest; 1089 } 1090 1091 1092 /***************************************************************************** 1093 * Name : 1094 * Purpose : 1095 * Parameters: 1096 * Variables : 1097 * Result : 1098 * Remark : 1099 * Status : UNTESTED STUB 1100 * 1101 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1102 *****************************************************************************/ 1103 // the real function calls 1104 ODINFUNCTION5(HANDLE, WSAAsyncGetProtoByName, HWND, hwnd, 1105 unsigned int, wMsg, 1106 const char*, name, 1107 char*, buf, 1108 int, buflen) 1109 { 1110 dprintf(("name = %s\n", name)); 1111 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETPROTOBYNAME, 1112 (HWND) hwnd, 1113 (ULONG)wMsg, 1114 (PVOID)buf, 1115 (ULONG)buflen, 1116 (ULONG)name); 1117 wsaWorker->pushRequest(pRequest); 1118 return (HANDLE)pRequest; 1119 } 1120 1121 1122 /***************************************************************************** 1123 * Name : 1124 * Purpose : 1125 * Parameters: 1126 * Variables : 1127 * Result : 1128 * Remark : 1129 * Status : UNTESTED STUB 1130 * 1131 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1132 *****************************************************************************/ 1133 // the real function calls 1134 ODINFUNCTION5(HANDLE, WSAAsyncGetProtoByNumber, HWND, hwnd, 1135 unsigned int, wMsg, 1136 int, number, 1137 char*, buf, 1138 int, buflen) 1139 { 1140 PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_GETPROTOBYNUMBER, 1141 (HWND) hwnd, 1142 (ULONG)wMsg, 1143 (PVOID)buf, 1144 (ULONG)buflen, 1145 (ULONG)number); 1146 wsaWorker->pushRequest(pRequest); 1147 return (HANDLE)pRequest; 1148 } 1149 1150 1151 /***************************************************************************** 1152 * Name : 1153 * Purpose : cancel a queued or busy request 1154 * Parameters: 1155 * Variables : 1156 * Result : 1157 * Remark : 1158 * Status : UNTESTED STUB 1159 * 1160 * Author : Patrick Haller [Tue, 1998/06/16 23:00] 1161 *****************************************************************************/ 1162 1163 ODINFUNCTION1(int, WSACancelAsyncRequest, HANDLE, hAsyncTaskHandle) 1164 { 1165 PASYNCREQUEST pRequest = (PASYNCREQUEST)hAsyncTaskHandle; 1166 BOOL rc; 1167 1168 // remove request from queue 1169 rc = wsaWorker->deleteRequest(pRequest); 1170 if (rc == TRUE) 1171 return 0; // success 1172 else 1173 { 1174 WSASetLastError(WSAEINVAL); 1175 return (SOCKET_ERROR); 1176 } 1177 } -
trunk/src/wsock32/makefile
r1318 r1372 1 # $Id: makefile,v 1. 8 1999-10-16 11:04:07 sandervlExp $1 # $Id: makefile,v 1.9 1999-10-20 10:03:53 phaller Exp $ 2 2 3 3 # … … 21 21 TARGET = wsock32 22 22 23 OBJS = wsock32.obj notify.obj initterm.obj unknown.obj 23 OBJS = wsock32.obj notify.obj initterm.obj unknown.obj async.obj 24 24 25 25 all: $(TARGET).dll $(TARGET).lib … … 40 40 $(IMPDEF) $** $@ 41 41 42 wsock32.obj: wsock32.cpp wsock32.h 42 wsock32.obj: wsock32.cpp wsock32.h wsock32const.h 43 43 notify.obj: notify.cpp wsock32.h 44 44 unknown.obj: unknown.cpp wsock32.h 45 async.obj: async.cpp wsock32const.h 45 46 initterm.obj: initterm.cpp 46 47 -
trunk/src/wsock32/wsock32.cpp
r1367 r1372 1 /* $Id: wsock32.cpp,v 1. 5 1999-10-20 01:18:31phaller Exp $ */1 /* $Id: wsock32.cpp,v 1.6 1999-10-20 10:03:53 phaller Exp $ */ 2 2 3 3 /* … … 55 55 #include <sys/time.h> 56 56 #include <win32type.h> 57 #include "wsock32const.h" 57 58 #include "wsock32.h" 58 59 #include "misc.h" … … 1482 1483 1483 1484 1484 // The following 6 calls need to start a new thread, perform1485 // the operation, copy ALL the info to the buffer provided then1486 // notify the sender.1487 1488 /*****************************************************************************1489 * Name :1490 * Purpose :1491 * Parameters:1492 * Variables :1493 * Result :1494 * Remark :1495 * Status : UNTESTED STUB1496 *1497 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1498 *****************************************************************************/1499 1500 ODINFUNCTION6(LHANDLE,OS2WSAAsyncGetServByName,HWND, hWnd,1501 u_int, wMsg,1502 const char*, name,1503 const char*, proto,1504 char*, buf,1505 int, buflen)1506 {1507 WSAStruct *wsa;1508 PFNTHREAD pfnAsyncThread = &WSAFunct; /* Address of thread program */1509 ULONG ulThreadParm = 100; /* Parameter to thread routine */1510 APIRET rc = NO_ERROR; /* Return code */1511 TID tid;1512 1513 1514 OS2WSASetLastError(WSAEWOULDBLOCK);1515 return 0;1516 1517 dprintf(("WSOCK32: WSAAsyncGetServByName. name: %s, proto: %s \n",1518 name,1519 proto));1520 1521 wsa = (WSAStruct *)malloc(sizeof(WSAStruct));1522 if(wsa == NULL)1523 {1524 OS2WSASetLastError(WSAEWOULDBLOCK);1525 return 0;1526 }1527 1528 wsa->CallingWhat = GETSERVBYNAME;1529 wsa->hw = hWnd;1530 wsa->msg = wMsg;1531 wsa->carg1 = strdup(name);1532 wsa->carg2 = strdup(proto);1533 wsa->buf = buf;1534 wsa->buflen = buflen;1535 1536 ulThreadParm = (ULONG)wsa;1537 1538 rc = DosCreateThread(&tid, /* Thread ID (returned by function) */1539 pfnAsyncThread, /* Address of thread program */1540 ulThreadParm, /* Parameter passed to ThreadProc */1541 CREATE_READY | /* Thread is ready when created */1542 STACK_SPARSE, /* Do not pre-commit stack pages */1543 8192L); /* Stack size, rounded to page bdy */1544 if (rc != NO_ERROR)1545 {1546 dprintf(("WSOCK32: DosCreateThread error in WSAAsyncGetServByName: return code = %u\n",1547 rc));1548 OS2WSASetLastError(rc);1549 free(wsa);1550 return 0;1551 }1552 1553 dprintf(("WSOCK32 THREAD: DosCreateThread's tid: %lu, ThreadParm = %p\n",1554 (unsigned long)tid,1555 ulThreadParm));1556 dprintf(("WSOCK32 THREAD: hwnd: %p\n",wsa->hw));1557 1558 return (LHANDLE)tid; //WSAAsyncGetServByName(hWnd,wMsg,name,proto,buf,buflen);1559 }1560 1561 1562 /*****************************************************************************1563 * Name :1564 * Purpose :1565 * Parameters:1566 * Variables :1567 * Result :1568 * Remark :1569 * Status : UNTESTED STUB1570 *1571 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1572 *****************************************************************************/1573 1574 ODINFUNCTION6(LHANDLE,OS2WSAAsyncGetServByPort,HWND, hWnd,1575 u_int, wMsg,1576 int, port,1577 const char*, proto,1578 char*, buf,1579 int, buflen)1580 {1581 dprintf(("WSOCK32: WSAAsyncGetServByPort unimplemented\n"));1582 1583 return -5000; //WSAAsyncGetServByPort(hWnd,wMsg,port,proto,buf,buflen);1584 }1585 1586 1587 /*****************************************************************************1588 * Name :1589 * Purpose :1590 * Parameters:1591 * Variables :1592 * Result :1593 * Remark :1594 * Status : UNTESTED STUB1595 *1596 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1597 *****************************************************************************/1598 1599 ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetProtoByName,HWND, hWnd,1600 u_int, wMsg,1601 const char*, name,1602 char *, buf,1603 int, buflen)1604 {1605 dprintf(("WSOCK32: WSAAsyncGetProtoByName unimplemented\n"));1606 return -5000; //WSAAsyncGetProtoByName(hWnd,wMsg,name,buf,buflen);1607 }1608 1609 1610 /*****************************************************************************1611 * Name :1612 * Purpose :1613 * Parameters:1614 * Variables :1615 * Result :1616 * Remark :1617 * Status : UNTESTED STUB1618 *1619 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1620 *****************************************************************************/1621 1622 ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetProtoByNumber,HWND, hWnd,1623 u_int, wMsg,1624 int, number,1625 char *, buf,1626 int, buflen)1627 {1628 dprintf(("WSOCK32: WSAAsyncGetProtoByNumber unimplemented\n"));1629 return -5000; //WSAAsyncGetProtoByNumber(hWnd,wMsg,number,buf,buflen);1630 }1631 1632 1633 /*****************************************************************************1634 * Name :1635 * Purpose :1636 * Parameters:1637 * Variables :1638 * Result :1639 * Remark :1640 * Status : UNTESTED STUB1641 *1642 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1643 *****************************************************************************/1644 1645 ODINFUNCTION5(LHANDLE,OS2WSAAsyncGetHostByName,HWND, hWnd,1646 u_int, wMsg,1647 const char *, name,1648 char *, buf,1649 int, buflen)1650 {1651 dprintf(("WSOCK32: WSAAsyncGetHostByName unimplemented\n"));1652 return -5000; //WSAAsyncGetHostByName(hWnd,wMsg,name,buf,buflen);1653 }1654 1655 1656 /*****************************************************************************1657 * Name :1658 * Purpose :1659 * Parameters:1660 * Variables :1661 * Result :1662 * Remark :1663 * Status : UNTESTED STUB1664 *1665 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1666 *****************************************************************************/1667 1668 ODINFUNCTION7(LHANDLE, OS2WSAAsyncGetHostByAddr, HWND, hWnd,1669 u_int, wMsg,1670 const char*, addr,1671 int, len,1672 int, type,1673 char*, buf,1674 int, buflen)1675 {1676 dprintf(("WSOCK32: WSAAsyncGetHostByAddr unimplemented\n"));1677 1678 return -5000; //WSAAsyncGetHostByAddr(hWnd,wMsg,addr,len,type,buf,buflen);1679 }1680 1681 1682 /*****************************************************************************1683 * Name :1684 * Purpose :1685 * Parameters:1686 * Variables :1687 * Result :1688 * Remark :1689 * Status : UNTESTED STUB1690 *1691 * Author : Patrick Haller [Tue, 1998/06/16 23:00]1692 *****************************************************************************/1693 1694 ODINFUNCTION1(int, OS2WSACancelAsyncRequest,LHANDLE,hAsyncTaskHandle)1695 {1696 TID tid;1697 APIRET rc;1698 1699 dprintf(("WSOCK32: WSACancelAsyncRequest unimplemented\n"));1700 1701 tid = (LHANDLE)hAsyncTaskHandle;1702 if(tid == 0)1703 rc = WSAEINVAL;1704 else1705 rc = DosKillThread(tid);1706 1707 switch(rc)1708 {1709 case 0: // SUCCESS!!1710 return 0;1711 case 170:1712 rc = WSAEINPROGRESS;1713 break;1714 case 309:1715 rc = WSAEINVAL;1716 break;1717 default:1718 rc = -5000;1719 break;1720 } // end switch1721 1722 OS2WSASetLastError(rc);1723 return SOCKET_ERROR; // ERROR!1724 }1725 1726 1727 1485 /***************************************************************************** 1728 1486 * Name : -
trunk/src/wsock32/wsock32.def
r283 r1372 1 ; $Id: wsock32.def,v 1. 5 1999-07-07 12:18:04phaller Exp $1 ; $Id: wsock32.def,v 1.6 1999-10-20 10:03:53 phaller Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler 4 4 LIBRARY WSOCK32 INITINSTANCE 5 5 DATA MULTIPLE NONSHARED 6 7 IMPORTS 8 PostMessageA = USER32.416 9 SetLastError = KERNEL32.654 10 GetLastError = KERNEL32.340 11 12 6 13 EXPORTS 7 14 ; _WSAFDIsSet = _OS2_WSAFDIsSet@8 … … 54 61 gethostname = _OS2gethostname@8 @57 55 62 56 WSAAsyncSelect = _OS2WSAAsyncSelect@16 @101 57 WSAAsyncGetHostByAddr = _OS2WSAAsyncGetHostByAddr@28 @102 58 WSAAsyncGetHostByName = _OS2WSAAsyncGetHostByName@20 @103 59 WSAAsyncGetProtoByNumber =_OS2WSAAsyncGetProtoByNumber@20 @104 60 WSAAsyncGetProtoByName = _OS2WSAAsyncGetProtoByName@20 @105 61 WSAAsyncGetServByPort = _OS2WSAAsyncGetServByPort@24 @106 62 WSAAsyncGetServByName = _OS2WSAAsyncGetServByName@24 @107 63 WSACancelAsyncRequest = _OS2WSACancelAsyncRequest@4 @108 63 WSAAsyncSelect = _OS2WSAAsyncSelect@16 @101 64 65 WSAAsyncGetHostByAddr = _WSAAsyncGetHostByAddr@28 @102 66 WSAAsyncGetHostByName = _WSAAsyncGetHostByName@20 @103 67 WSAAsyncGetProtoByNumber = _WSAAsyncGetProtoByNumber@20 @104 68 WSAAsyncGetProtoByName = _WSAAsyncGetProtoByName@20 @105 69 WSAAsyncGetServByPort = _WSAAsyncGetServByPort@24 @106 70 WSAAsyncGetServByName = _WSAAsyncGetServByName@24 @107 71 WSACancelAsyncRequest = _WSACancelAsyncRequest@4 @108 72 64 73 WSASetBlockingHook = _OS2WSASetBlockingHook@4 @109 65 74 WSAUnhookBlockingHook = _OS2WSAUnhookBlockingHook@0 @110 -
trunk/src/wsock32/wsock32.h
r518 r1372 1 /* $Id: wsock32.h,v 1. 4 1999-08-16 20:18:40phaller Exp $ */1 /* $Id: wsock32.h,v 1.5 1999-10-20 10:03:54 phaller Exp $ */ 2 2 3 3 /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll. … … 400 400 */ 401 401 402 /*403 * This is used instead of -1, since the404 * SOCKET type is unsigned.405 */406 #define INVALID_SOCKET (SOCKET)(~0)407 #define SOCKET_ERROR (-1)408 402 409 403 /* … … 561 555 #define FD_CONNECT 0x10 562 556 #define FD_CLOSE 0x20 563 564 /*565 * All Windows Sockets error constants are biased by WSABASEERR from566 * the "normal"567 */568 #define WSABASEERR 10000569 /*570 * Windows Sockets definitions of regular Microsoft C error constants571 */572 #define WSAEINTR (WSABASEERR+4)573 #define WSAEBADF (WSABASEERR+9)574 #define WSAEACCES (WSABASEERR+13)575 #define WSAEFAULT (WSABASEERR+14)576 #define WSAEINVAL (WSABASEERR+22)577 #define WSAEMFILE (WSABASEERR+24)578 579 /*580 * Windows Sockets definitions of regular Berkeley error constants581 */582 #define WSAEWOULDBLOCK (WSABASEERR+35)583 #define WSAEINPROGRESS (WSABASEERR+36)584 #define WSAEALREADY (WSABASEERR+37)585 #define WSAENOTSOCK (WSABASEERR+38)586 #define WSAEDESTADDRREQ (WSABASEERR+39)587 #define WSAEMSGSIZE (WSABASEERR+40)588 #define WSAEPROTOTYPE (WSABASEERR+41)589 #define WSAENOPROTOOPT (WSABASEERR+42)590 #define WSAEPROTONOSUPPORT (WSABASEERR+43)591 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)592 #define WSAEOPNOTSUPP (WSABASEERR+45)593 #define WSAEPFNOSUPPORT (WSABASEERR+46)594 #define WSAEAFNOSUPPORT (WSABASEERR+47)595 #define WSAEADDRINUSE (WSABASEERR+48)596 #define WSAEADDRNOTAVAIL (WSABASEERR+49)597 #define WSAENETDOWN (WSABASEERR+50)598 #define WSAENETUNREACH (WSABASEERR+51)599 #define WSAENETRESET (WSABASEERR+52)600 #define WSAECONNABORTED (WSABASEERR+53)601 #define WSAECONNRESET (WSABASEERR+54)602 #define WSAENOBUFS (WSABASEERR+55)603 #define WSAEISCONN (WSABASEERR+56)604 #define WSAENOTCONN (WSABASEERR+57)605 #define WSAESHUTDOWN (WSABASEERR+58)606 #define WSAETOOMANYREFS (WSABASEERR+59)607 #define WSAETIMEDOUT (WSABASEERR+60)608 #define WSAECONNREFUSED (WSABASEERR+61)609 #define WSAELOOP (WSABASEERR+62)610 #define WSAENAMETOOLONG (WSABASEERR+63)611 #define WSAEHOSTDOWN (WSABASEERR+64)612 #define WSAEHOSTUNREACH (WSABASEERR+65)613 #define WSAENOTEMPTY (WSABASEERR+66)614 #define WSAEPROCLIM (WSABASEERR+67)615 #define WSAEUSERS (WSABASEERR+68)616 #define WSAEDQUOT (WSABASEERR+69)617 #define WSAESTALE (WSABASEERR+70)618 #define WSAEREMOTE (WSABASEERR+71)619 620 #define WSAEDISCON (WSABASEERR+101)621 622 /*623 * Extended Windows Sockets error constant definitions624 */625 #define WSASYSNOTREADY (WSABASEERR+91)626 #define WSAVERNOTSUPPORTED (WSABASEERR+92)627 #define WSANOTINITIALISED (WSABASEERR+93)628 629 /*630 * Error return codes from gethostbyname() and gethostbyaddr()631 * (when using the resolver). Note that these errors are632 * retrieved via WSAGetLastError() and must therefore follow633 * the rules for avoiding clashes with error numbers from634 * specific implementations or language run-time systems.635 * For this reason the codes are based at WSABASEERR+1001.636 * Note also that [WSA]NO_ADDRESS is defined only for637 * compatibility purposes.638 */639 640 #define Wh_errno WSAGetLastError()641 642 /* Authoritative Answer: Host not found */643 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)644 #define WHOST_NOT_FOUND WSAHOST_NOT_FOUND645 646 /* Non-Authoritative: Host not found, or SERVERFAIL */647 #define WSATRY_AGAIN (WSABASEERR+1002)648 #define WTRY_AGAIN WSATRY_AGAIN649 650 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */651 #define WSANO_RECOVERY (WSABASEERR+1003)652 #define WNO_RECOVERY WSANO_RECOVERY653 654 /* Valid name, no data record of requested type */655 #define WSANO_DATA (WSABASEERR+1004)656 #define WNO_DATA WSANO_DATA657 658 /* no address, look for MX record */659 #define WSANO_ADDRESS WSANO_DATA660 #define WNO_ADDRESS WSANO_ADDRESS661 557 662 558
Note:
See TracChangeset
for help on using the changeset viewer.