- Timestamp:
- Jul 7, 2001, 12:44:11 PM (24 years ago)
- Location:
- trunk/src/wsock32
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/asyncapi.cpp
r5625 r6196 1 /* $Id: asyncapi.cpp,v 1. 9 2001-04-28 16:15:18 sandervlExp $ */1 /* $Id: asyncapi.cpp,v 1.10 2001-07-07 10:44:08 achimha Exp $ */ 2 2 3 3 /* … … 156 156 157 157 if(!pThreadParm->fCancelled) { 158 dprintf(("WSAsyncThreadProc %x %x %x %x", pThreadParm-> hwnd, pThreadParm->msg, pThreadParm->hAsyncTaskHandle, lParam));159 PostMessageA( pThreadParm->hwnd, pThreadParm->msg,158 dprintf(("WSAsyncThreadProc %x %x %x %x", pThreadParm->notifyHandle, pThreadParm->notifyData, pThreadParm->hAsyncTaskHandle, lParam)); 159 PostMessageA((HWND)pThreadParm->notifyHandle, (DWORD)pThreadParm->notifyData, 160 160 (WPARAM)pThreadParm->hAsyncTaskHandle, lParam); 161 161 } … … 203 203 } 204 204 memset(pThreadParm, 0, sizeof(*pThreadParm)); 205 pThreadParm->request = requesttype;206 pThreadParm-> hwnd =hwnd;207 pThreadParm-> msg =msg;208 pThreadParm->buf = buf;209 pThreadParm->buflen = buflen;205 pThreadParm->request = requesttype; 206 pThreadParm->notifyHandle = (int)hwnd; 207 pThreadParm->notifyData = (int)msg; 208 pThreadParm->buf = buf; 209 pThreadParm->buflen = buflen; 210 210 211 211 switch(requesttype) { … … 399 399 //****************************************************************************** 400 400 //****************************************************************************** 401 void AsyncNotifyEvent(PASYNCTHREADPARM pThreadParm, ULONG event, ULONG socket_error) 402 { 403 pThreadParm->u.asyncselect.lEventsPending &= ~event; 404 405 event = WSAMAKESELECTREPLY(event, socket_error); 406 407 dprintf(("AsyncNotifyEvent %x %x %x %x", pThreadParm->u.asyncselect.s, pThreadParm->hwnd, pThreadParm->msg, event)); 408 PostMessageA(pThreadParm->hwnd, pThreadParm->msg, (WPARAM)pThreadParm->u.asyncselect.s, 409 (LPARAM)event); 401 void AsyncSelectNotifyEvent(PASYNCTHREADPARM pThreadParm, ULONG event, ULONG socket_error) 402 { 403 pThreadParm->u.asyncselect.lEventsPending &= ~event; 404 405 event = WSAMAKESELECTREPLY(event, socket_error); 406 407 if (pThreadParm->u.asyncselect.mode == WSA_SELECT_HWND) 408 { 409 dprintf(("AsyncSelectNotifyEvent: notifying window %x %x %x %x", pThreadParm->u.asyncselect.s, pThreadParm->notifyHandle, pThreadParm->notifyData, event)); 410 PostMessageA((HWND)pThreadParm->notifyHandle, (DWORD)pThreadParm->notifyData, (WPARAM)pThreadParm->u.asyncselect.s, 411 (LPARAM)event); 412 } 413 else 414 if (pThreadParm->u.asyncselect.mode == WSA_SELECT_HEVENT) 415 { 416 dprintf(("AsyncSelectNotifyEvent: notifying event semaphore %x %x %x %x", pThreadParm->u.asyncselect.s, pThreadParm->notifyHandle, pThreadParm->notifyData, event)); 417 SetEvent(pThreadParm->notifyHandle); 418 } 419 else 420 { 421 dprintf(("AsyncSelectNotifyEvent: error, unknown mode")); 422 } 410 423 } 411 424 //****************************************************************************** … … 483 496 if(lEventsPending & FD_CLOSE) { 484 497 dprintf(("FD_CLOSE; broken connection")); 485 Async NotifyEvent(pThreadParm, FD_CLOSE, WSAECONNRESET);498 AsyncSelectNotifyEvent(pThreadParm, FD_CLOSE, WSAECONNRESET); 486 499 } 487 500 … … 494 507 if(lEventsPending & FD_CLOSE) { 495 508 dprintf(("FD_CLOSE; SOCEINVAL")); 496 Async NotifyEvent(pThreadParm, FD_CLOSE, selecterr);509 AsyncSelectNotifyEvent(pThreadParm, FD_CLOSE, selecterr); 497 510 } 498 511 break; … … 510 523 if(lEventsPending & FD_CONNECT) { 511 524 if(state & SS_ISCONNECTED) { 512 Async NotifyEvent(pThreadParm, FD_CONNECT, NO_ERROR);525 AsyncSelectNotifyEvent(pThreadParm, FD_CONNECT, NO_ERROR); 513 526 } 514 527 else { … … 519 532 //SvL: WSeB returns SOCECONNREFUSED, Warp 4 0x3d 520 533 if(sockoptval == SOCECONNREFUSED || sockoptval == (SOCECONNREFUSED - SOCBASEERR)) { 521 Async NotifyEvent(pThreadParm, FD_CONNECT, WSAECONNREFUSED);534 AsyncSelectNotifyEvent(pThreadParm, FD_CONNECT, WSAECONNREFUSED); 522 535 } 523 536 } … … 525 538 else 526 539 if(!(state & SS_CANTSENDMORE) && (lEventsPending & FD_WRITE)) { 527 Async NotifyEvent(pThreadParm, FD_WRITE, NO_ERROR);540 AsyncSelectNotifyEvent(pThreadParm, FD_WRITE, NO_ERROR); 528 541 } 529 542 } … … 537 550 { 538 551 dprintf(("FD_CLOSE; ioctl; socket error")); 539 Async NotifyEvent(pThreadParm, FD_CLOSE, NO_ERROR);552 AsyncSelectNotifyEvent(pThreadParm, FD_CLOSE, NO_ERROR); 540 553 //remote connection broken (so can't receive data anymore) 541 554 //but can still send … … 559 572 } 560 573 if((sockoptval & SO_ACCEPTCONN) == SO_ACCEPTCONN) { 561 Async NotifyEvent(pThreadParm, FD_ACCEPT, NO_ERROR);574 AsyncSelectNotifyEvent(pThreadParm, FD_ACCEPT, NO_ERROR); 562 575 } 563 576 } 564 577 if((lEventsPending & FD_READ) && bytesread >= 0) { 565 Async NotifyEvent(pThreadParm, FD_READ, NO_ERROR);578 AsyncSelectNotifyEvent(pThreadParm, FD_READ, NO_ERROR); 566 579 } 567 580 #if 0 … … 571 584 if((lEventsPending & FD_CLOSE) && (state == 0 && bytesread == 0)) { 572 585 dprintf(("FD_CLOSE; state == 0 && bytesread == 0")); 573 Async NotifyEvent(pThreadParm, FD_CLOSE, NO_ERROR);586 AsyncSelectNotifyEvent(pThreadParm, FD_CLOSE, NO_ERROR); 574 587 } 575 588 #endif … … 578 591 { 579 592 if(lEventsPending & FD_OOB) { 580 Async NotifyEvent(pThreadParm, FD_OOB, NO_ERROR);593 AsyncSelectNotifyEvent(pThreadParm, FD_OOB, NO_ERROR); 581 594 } 582 595 } … … 600 613 long,lEvent) 601 614 { 615 /* just forward call to worker method */ 616 return WSAAsyncSelectWorker(s, WSA_SELECT_HWND, (int)hWnd, (int)wMsg, lEvent); 617 } 618 //****************************************************************************** 619 //****************************************************************************** 620 int WSAAsyncSelectWorker(SOCKET s, int mode, int notifyHandle, int notifyData, long lEventMask) 621 { 602 622 PASYNCTHREADPARM pThreadParm; 603 623 int nonblock = 1; 604 624 int ret; 605 625 626 #ifdef DEBUG 627 // log all event bits that are set 628 char tmpbuf[300]; 629 strcpy(tmpbuf, ""); 630 if (lEventMask & FD_READ) 631 strcat(tmpbuf, " FD_READ"); 632 if (lEventMask & FD_WRITE) 633 strcat(tmpbuf, " FD_WRITE"); 634 if (lEventMask & FD_OOB) 635 strcat(tmpbuf, " FD_OOB"); 636 if (lEventMask & FD_ACCEPT) 637 strcat(tmpbuf, " FD_ACCEPT"); 638 if (lEventMask & FD_CONNECT) 639 strcat(tmpbuf, " FD_CONNECT"); 640 if (lEventMask & FD_CLOSE) 641 strcat(tmpbuf, " FD_CLOSE"); 642 if (lEventMask & FD_QOS) 643 strcat(tmpbuf, " FD_QOS"); 644 if (lEventMask & FD_GROUP_QOS) 645 strcat(tmpbuf, " FD_GROUP_QOS"); 646 if (lEventMask & FD_ROUTING_INTERFACE_CHANGE) 647 strcat(tmpbuf, " FD_ROUTING_INTERFACE_CHANGE"); 648 if (lEventMask & FD_ADDRESS_LIST_CHANGE) 649 strcat(tmpbuf, " FD_ADDRESS_LIST_CHANGE"); 650 dprintf(("event bits:%s", tmpbuf)); 651 #endif 652 606 653 if(!fWSAInitialized) 607 654 { 655 dprintf(("WSA sockets not initialized")); 608 656 WSASetLastError(WSANOTINITIALISED); 609 657 return SOCKET_ERROR; … … 612 660 if(WSAIsBlocking()) 613 661 { 662 dprintf(("blocking call in progress")); 614 663 WSASetLastError(WSAEINPROGRESS); // blocking call in progress 615 664 return SOCKET_ERROR; 616 665 } 617 666 else 618 if(hWnd && !IsWindow(hWnd)) 619 { 667 if((mode == WSA_SELECT_HWND) && (HWND)notifyHandle && !IsWindow((HWND)notifyHandle)) 668 { 669 dprintf(("invalid window handle")); 620 670 WSASetLastError(WSAEINVAL); // invalid parameter 621 671 return SOCKET_ERROR; 622 672 } 673 #if 0 674 // AH: null sempahore is ok when clearing request 675 else 676 if ((mode == WSA_SELECT_HEVENT) && !(WSAEVENT)notifyHandle) 677 { 678 dprintf(("invalid event semaphore handle")); 679 WSASetLastError(WSAEINVAL); // invalid parameter 680 return SOCKET_ERROR; 681 } 682 #endif 683 623 684 //Set socket to non-blocking mode 624 685 ret = ioctl(s, FIONBIO, (char *) &nonblock, sizeof(nonblock)); 625 686 if(ret == SOCKET_ERROR) { 687 dprintf(("setting socket to non blocking mode failed")); 626 688 WSASetLastError(wsaErrno()); 627 689 return SOCKET_ERROR; 628 690 } 629 if(FindAndSetAsyncEvent(s, hWnd, wMsg, lEvent) == TRUE) { 691 if(FindAndSetAsyncEvent(s, mode, notifyHandle, notifyData, lEventMask) == TRUE) 692 { 693 dprintf(("already got socket, just changing event mask")); 630 694 //found and changed active async event 631 695 WSASetLastError(NO_ERROR); … … 640 704 } 641 705 memset(pThreadParm, 0, sizeof(*pThreadParm)); 642 pThreadParm->request= ASYNC_SELECT; 643 pThreadParm->hwnd = hWnd; 644 pThreadParm->msg = wMsg; 645 pThreadParm->u.asyncselect.lEvents = lEvent; 646 pThreadParm->u.asyncselect.lEventsPending = lEvent; 706 pThreadParm->request = ASYNC_SELECT; 707 pThreadParm->notifyHandle = notifyHandle; 708 pThreadParm->notifyData = notifyData; 709 pThreadParm->u.asyncselect.mode = mode; 710 pThreadParm->u.asyncselect.lEvents = lEventMask; 711 pThreadParm->u.asyncselect.lEventsPending = lEventMask; 647 712 pThreadParm->u.asyncselect.s = s; 648 713 pThreadParm->u.asyncselect.asyncSem = new VSemaphore; -
trunk/src/wsock32/asyncthread.cpp
r5638 r6196 1 /* $Id: asyncthread.cpp,v 1. 9 2001-04-29 18:47:31 sandervlExp $ */1 /* $Id: asyncthread.cpp,v 1.10 2001-07-07 10:44:09 achimha Exp $ */ 2 2 3 3 /* … … 208 208 //****************************************************************************** 209 209 //****************************************************************************** 210 BOOL FindAndSetAsyncEvent(SOCKET s, HWND hwnd, int msg, ULONG lEvent)210 BOOL FindAndSetAsyncEvent(SOCKET s, int mode, int notifyHandle, int notifyData, ULONG lEventMask) 211 211 { 212 212 PASYNCTHREADPARM pThreadInfo; … … 215 215 pThreadInfo = FindAsyncEvent(s); 216 216 if(pThreadInfo) { 217 pThreadInfo->u.asyncselect.lEvents = lEvent; 218 pThreadInfo->u.asyncselect.lEventsPending = lEvent; 219 pThreadInfo->hwnd = hwnd; 220 pThreadInfo->msg = msg; 221 if(lEvent == 0) { 217 pThreadInfo->u.asyncselect.mode = mode; 218 pThreadInfo->u.asyncselect.lEvents = lEventMask; 219 pThreadInfo->u.asyncselect.lEventsPending = lEventMask; 220 pThreadInfo->notifyHandle = notifyHandle; 221 pThreadInfo->notifyData = notifyData; 222 if(lEventMask == 0) { 222 223 //make sure this thread isn't used anymore 223 224 pThreadInfo->fRemoved = TRUE; … … 263 264 pThreadInfo = FindAsyncEvent(s); 264 265 if(pThreadInfo) { 265 *pHwnd = pThreadInfo->hwnd;266 *pMsg = pThreadInfo-> msg;266 *pHwnd = (HWND)pThreadInfo->notifyHandle; 267 *pMsg = pThreadInfo->notifyData; 267 268 *plEvent = pThreadInfo->u.asyncselect.lEvents; 268 269 } -
trunk/src/wsock32/asyncthread.h
r3557 r6196 1 /* $Id: asyncthread.h,v 1. 5 2000-05-18 22:54:21 sandervlExp $ */1 /* $Id: asyncthread.h,v 1.6 2001-07-07 10:44:09 achimha Exp $ */ 2 2 3 3 /* … … 40 40 ASYNCTHREADPROC asyncProc; 41 41 VMutex *parmmutex; 42 HWND hwnd;43 DWORD msg;42 int notifyHandle; 43 int notifyData; 44 44 LPSTR buf; 45 45 DWORD buflen; … … 72 72 DWORD lEventsPending; 73 73 SOCKET s; 74 int mode; 74 75 } asyncselect; 75 76 } u; … … 82 83 void EnableAsyncEvent(SOCKET s, ULONG flags); 83 84 BOOL QueryAsyncEvent(SOCKET s, HWND *pHwnd, int *pMsg, ULONG *plEvent); 84 BOOL FindAndSetAsyncEvent(SOCKET s, HWND hwnd, int msg, ULONG lEvent);85 BOOL FindAndSetAsyncEvent(SOCKET s, int mode, int notifyHandle, int notifyData, ULONG lEventMask); 85 86 86 87 #endif //__ASYNCTHREAD_H__ -
trunk/src/wsock32/makefile
r4717 r6196 1 # $Id: makefile,v 1. 29 2000-12-02 23:43:27 birdExp $1 # $Id: makefile,v 1.30 2001-07-07 10:44:09 achimha Exp $ 2 2 3 3 # … … 32 32 $(OBJDIR)\asyncapi.obj \ 33 33 $(OBJDIR)\asyncthread.obj \ 34 $(OBJDIR)\dbglocal.obj 34 $(OBJDIR)\dbglocal.obj \ 35 $(OBJDIR)\wsock2.obj 35 36 36 37 -
trunk/src/wsock32/wsock32.cpp
r5625 r6196 1 /* $Id: wsock32.cpp,v 1.3 5 2001-04-28 16:15:18 sandervlExp $ */1 /* $Id: wsock32.cpp,v 1.36 2001-07-07 10:44:10 achimha Exp $ */ 2 2 3 3 /* … … 154 154 // to SetLastError() 155 155 if(iError) { 156 dprintf(("WSASetLastError %x", iError));156 dprintf(("WSASetLastError 0x%x", iError)); 157 157 } 158 158 SetLastError(iError); … … 236 236 } 237 237 //Close WSAAsyncSelect thread if one was created for this socket 238 FindAndSetAsyncEvent(s, 0, 0, 0);238 FindAndSetAsyncEvent(s, WSA_SELECT_HWND, 0, 0, 0); 239 239 240 240 // wait thread termination … … 863 863 864 864 if(!fWSAInitialized) { 865 WSASetLastError(WSANOTINITIALISED); 866 return SOCKET_ERROR; 867 } 868 else 869 if(WSAIsBlocking()) { 865 dprintf(("WSA not initialized")); 866 WSASetLastError(WSANOTINITIALISED); 867 return SOCKET_ERROR; 868 } 869 else 870 if(WSAIsBlocking()) { 871 dprintf(("WSA is blocking")); 870 872 WSASetLastError(WSAEINPROGRESS); 871 873 return SOCKET_ERROR; … … 887 889 case SO_LINGER: 888 890 if(optlen < (int)sizeof(ws_linger)) { 891 dprintf(("SOL_SOCKET, SO_LINGER, optlen too small")); 889 892 WSASetLastError(WSAEFAULT); 890 893 return SOCKET_ERROR; … … 899 902 case SO_RCVBUF: 900 903 if(optlen < (int)sizeof(int)) { 904 dprintf(("SOL_SOCKET, SO_RCVBUF, optlen too small")); 901 905 WSASetLastError(WSAEFAULT); 902 906 return SOCKET_ERROR; … … 923 927 case SO_REUSEADDR: 924 928 if(optlen < (int)sizeof(int)) { 929 dprintf(("SOL_SOCKET, SO_REUSEADDR, optlen too small")); 925 930 WSASetLastError(WSAEFAULT); 926 931 return SOCKET_ERROR; … … 938 943 if(optname == TCP_NODELAY) { 939 944 if(optlen < (int)sizeof(int)) { 945 dprintf(("IPPROTO_TCP, TCP_NODELAY, optlen too small")); 940 946 WSASetLastError(WSAEFAULT); 941 947 return SOCKET_ERROR; … … 950 956 } 951 957 else { 958 dprintf(("unknown level code!")); 952 959 WSASetLastError(WSAEINVAL); 953 960 return SOCKET_ERROR; -
trunk/src/wsock32/wsock32.def
r4809 r6196 1 ; $Id: wsock32.def,v 1.2 1 2000-12-16 22:53:51 birdExp $1 ; $Id: wsock32.def,v 1.22 2001-07-07 10:44:11 achimha Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 112 112 113 113 _OS2gethostname@8 @2000 114 115 ; functions for ws2_32 implemented here 116 WSAEventSelect = _WSAEventSelect@12 @3001 -
trunk/src/wsock32/wsock32.h
r5279 r6196 1 /* $Id: wsock32.h,v 1.1 6 2001-02-28 20:28:09 sandervlExp $ */1 /* $Id: wsock32.h,v 1.17 2001-07-07 10:44:11 achimha Exp $ */ 2 2 3 3 /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll. … … 51 51 52 52 // WSAAsyncSelect flags 53 #define FD_READ 0x01 54 #define FD_WRITE 0x02 55 #define FD_OOB 0x04 56 #define FD_ACCEPT 0x08 57 #define FD_CONNECT 0x10 58 #define FD_CLOSE 0x20 53 // also apply to Winsock 2.0 WSAEventSelect 54 #define FD_READ 0x01 55 #define FD_WRITE 0x02 56 #define FD_OOB 0x04 57 #define FD_ACCEPT 0x08 58 #define FD_CONNECT 0x10 59 #define FD_CLOSE 0x20 60 // Winsock 2.0 only 61 #define FD_QOS 0x40 62 #define FD_GROUP_QOS 0x80 63 #define FD_ROUTING_INTERFACE_CHANGE 0x100 64 #define FD_ADDRESS_LIST_CHANGE 0x200 59 65 60 66 #define SOCKET_ERROR -1 … … 235 241 LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD); 236 242 243 typedef HANDLE WSAEVENT; 244 245 // modes for the async select worker 246 #define WSA_SELECT_HWND 1 247 #define WSA_SELECT_HEVENT 2 248 // async select worker routine 249 int WSAAsyncSelectWorker(SOCKET s, int mode, int notifyHandle, int notifyData, long lEventMask); 250 237 251 #endif /* _WINSOCK32CONST_ */ 238 252 -
trunk/src/wsock32/wsock32rsrc.orc
r4952 r6196 1 /* $Id: wsock32rsrc.orc,v 1. 3 2001-01-14 21:00:06 sandervlExp $ */1 /* $Id: wsock32rsrc.orc,v 1.4 2001-07-07 10:44:11 achimha Exp $ */ 2 2 3 3 #include "winuser.h" … … 28 28 VALUE "FileVersion", "4.00\0" 29 29 VALUE "InternalName", "WSOCK32\0" 30 VALUE "LegalCopyright", "Copyright (C) 1999-200 0\0"30 VALUE "LegalCopyright", "Copyright (C) 1999-2001\0" 31 31 VALUE "LegalTrademarks", "\0" 32 32 VALUE "OriginalFilename", "WSOCK32.DLL\0"
Note:
See TracChangeset
for help on using the changeset viewer.