- Timestamp:
- Feb 23, 2002, 5:39:10 PM (24 years ago)
- Location:
- trunk/src/wsock32
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/asyncapi.cpp
r7977 r7992 1 /* $Id: asyncapi.cpp,v 1. 19 2002-02-20 15:07:13sandervl Exp $ */1 /* $Id: asyncapi.cpp,v 1.20 2002-02-23 16:39:09 sandervl Exp $ */ 2 2 3 3 /* … … 531 531 ret = select((int *)sockets, nr(noread), nr(nowrite), nr(noexcept), -1); 532 532 pThreadParm->fWaitSelect = FALSE; 533 533 534 if(ret == SOCKET_ERROR) { 534 535 int selecterr = sock_errno(); … … 542 543 //// state = ioctl(s, FIOBSTATUS, (char *)&tmp, sizeof(tmp)); 543 544 //// dprintf(("SOCEINTR; state = %x", state)); 544 goto asyncloopstart; //so_cancel was called545 goto asyncloopstart; //so_cancel/closesocket was called 545 546 546 547 case SOCECONNRESET: … … 574 575 state = ioctl(s, FIOBSTATUS, (char *)&tmp, sizeof(tmp)); 575 576 576 if(lEventsPending & FD_CONNECT) { 577 //Don't send FD_CONNECT is socket was already connected (accept returns connected socket) 578 if(!pThreadParm->fConnected && (lEventsPending & FD_CONNECT)) 579 { 577 580 if(state & SS_ISCONNECTED) { 578 581 AsyncSelectNotifyEvent(pThreadParm, FD_CONNECT, NO_ERROR); 582 pThreadParm->fConnected = TRUE; 579 583 } 580 584 else { … … 594 598 } 595 599 } 596 597 600 if(ready(noread)) 598 601 { 599 602 state = ioctl(s, FIONREAD, (CHAR *) &bytesread, sizeof(bytesread)); 603 dprintf2(("state %x, bytesread %d", state, bytesread)); 600 604 if(state == SOCKET_ERROR) 601 605 { … … 769 773 return SOCKET_ERROR; 770 774 } 775 776 int size, state, tmp; 777 state = ioctl(s, FIOBSTATUS, (char *)&tmp, sizeof(tmp)); 778 dprintf(("QueueAsyncJob: state %x", state)); 779 780 //Don't send FD_CONNECT is socket was already connected (accept returns connected socket) 781 if(state & SS_ISCONNECTED) { 782 pThreadParm->fConnected = TRUE; 783 } 784 else pThreadParm->fConnected = FALSE; 785 771 786 if(QueueAsyncJob(WSAsyncSelectThreadProc, pThreadParm) == 0) { 772 787 delete pThreadParm->u.asyncselect.asyncSem; -
trunk/src/wsock32/asyncthread.cpp
r7977 r7992 1 /* $Id: asyncthread.cpp,v 1.1 4 2002-02-20 15:07:13sandervl Exp $ */1 /* $Id: asyncthread.cpp,v 1.15 2002-02-23 16:39:09 sandervl Exp $ */ 2 2 3 3 /* … … 239 239 { 240 240 PASYNCTHREADPARM pThreadInfo; 241 241 242 242 asyncThreadMutex.enter(); 243 243 pThreadInfo = FindAsyncEvent(s); 244 if(pThreadInfo) { 244 if(pThreadInfo) 245 { 246 int size, state, tmp; 247 state = ioctl(s, FIOBSTATUS, (char *)&tmp, sizeof(tmp)); 248 dprintf(("FindAndSetAsyncEvent: state %x", state)); 249 250 //Don't send FD_CONNECT is socket was already connected (accept returns connected socket) 251 if(state & SS_ISCONNECTED) { 252 pThreadInfo->fConnected = TRUE; 253 } 254 else pThreadInfo->fConnected = FALSE; 255 245 256 pThreadInfo->u.asyncselect.mode = mode; 246 257 pThreadInfo->u.asyncselect.lEvents = lEventMask; -
trunk/src/wsock32/asyncthread.h
r7977 r7992 1 /* $Id: asyncthread.h,v 1.1 1 2002-02-20 15:07:14sandervl Exp $ */1 /* $Id: asyncthread.h,v 1.12 2002-02-23 16:39:09 sandervl Exp $ */ 2 2 3 3 /* … … 33 33 BOOL fCancelled; 34 34 BOOL fConnected; 35 BOOL fWaitSelect; 35 BOOL fWaitSelect; 36 36 BOOL fRemoved; //async select 37 37 AsyncRequestType request; -
trunk/src/wsock32/wsock32.cpp
r7979 r7992 1 /* $Id: wsock32.cpp,v 1.4 8 2002-02-20 16:08:03sandervl Exp $ */1 /* $Id: wsock32.cpp,v 1.49 2002-02-23 16:39:10 sandervl Exp $ */ 2 2 3 3 /* … … 65 65 #include "dbglocal.h" 66 66 67 //kso: dirty fix to make this compile! not permanent! 68 BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER *p); 69 #define LowPart u.LowPart 70 67 // 68 #define DUMP_PACKETS 71 69 72 70 ODINDEBUGCHANNEL(WSOCK32-WSOCK32) 73 74 71 75 72 /***************************************************************************** … … 209 206 strcpy(msg, "WSAHOST_NOT_FOUND"); 210 207 break; 208 case WSAENOPROTOOPT: 209 strcpy(msg, "WSAENOPROTOOPT"); 210 break; 211 case WSAEHOSTUNREACH: 212 strcpy(msg, "WSAEHOSTUNREACH"); 213 break; 211 214 default: 212 215 strcpy(msg, "unknown"); … … 326 329 return SOCKET_ERROR; 327 330 } 331 dprintf(("connect to %s", inet_ntoa(((sockaddr_in*)name)->sin_addr))); 332 328 333 ret = connect(s, (sockaddr *)name, namelen); 329 334 // map BSD error codes … … 550 555 //with the same parameters for the new socket (see docs) 551 556 if(QueryAsyncEvent(s, &mode, ¬ifyHandle, ¬ifyData, &lEvent) == TRUE) { 557 dprintf(("Setting async select for socket %x, mode %d, %x %x %x", ret, mode, notifyHandle, notifyData, lEvent)); 552 558 if(WSAAsyncSelectWorker(ret, mode, notifyHandle, notifyData, lEvent) == SOCKET_ERROR) { 553 559 ret = SOCKET_ERROR; … … 584 590 return SOCKET_ERROR; 585 591 } 592 dprintf(("bind to %s", inet_ntoa(((sockaddr_in*)addr)->sin_addr))); 586 593 ret = bind(s, (struct sockaddr *)addr, namelen); 587 594 … … 682 689 } 683 690 } 684 else WSASetLastError(NO_ERROR); 691 else { 692 #ifdef DUMP_PACKETS 693 dprintf(("Packet length %d", ret)); 694 for(int i=0;i<(ret+7)/8;i++) { 695 dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7])); 696 } 697 #endif 698 WSASetLastError(NO_ERROR); 699 } 685 700 686 701 //Reset FD_READ event flagfor WSAAsyncSelect thread if one was created for this socket … … 714 729 return SOCKET_ERROR; 715 730 } 731 dprintf(("recvfrom to %s", inet_ntoa(((sockaddr_in*)from)->sin_addr))); 732 716 733 ret = recvfrom(s, buf, len, flags, from, fromlen); 717 734 … … 719 736 WSASetLastError(wsaErrno()); 720 737 } 721 else WSASetLastError(NO_ERROR); 738 else { 739 #ifdef DUMP_PACKETS 740 dprintf(("Packet length %d", ret)); 741 for(int i=0;i<(ret+7)/8;i++) { 742 dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7])); 743 } 744 #endif 745 WSASetLastError(NO_ERROR); 746 } 722 747 723 748 //Reset FD_READ event flagfor WSAAsyncSelect thread if one was created for this socket … … 734 759 { 735 760 int ret; 761 int optlen; 762 int option; 736 763 737 764 if(!fWSAInitialized) { … … 744 771 return SOCKET_ERROR; 745 772 } 773 // check if the socket is a raw socket and has the IP_HDRINCL switch 774 // if this is the case, we overwrite the IP header length field with 775 // the actual length because some apps tend to put garbage in there 776 // and rely on Windows to correct this 777 optlen = sizeof(option); 778 option = 0; 779 ret = getsockopt(s, IPPROTO_IP, IP_HDRINCL_OS2, (char *)&option, &optlen); 780 if(ret == 0 && option != FALSE) { 781 *(u_short *)&buf[2] = len; 782 } 783 784 #ifdef DUMP_PACKETS 785 dprintf(("Packet length %d", len)); 786 for(int i=0;i<(len+7)/8;i++) { 787 dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7])); 788 } 789 #endif 746 790 ret = send(s, (char *)buf, len, flags); 747 791 … … 785 829 // check if the socket is a raw socket and has the IP_HDRINCL switch 786 830 // if this is the case, we overwrite the IP header length field with 787 // the actual length because some apps tend to put ingarbage in there788 // and rely on Windows correctingthis831 // the actual length because some apps tend to put garbage in there 832 // and rely on Windows to correct this 789 833 optlen = sizeof(option); 790 834 option = 0; … … 794 838 } 795 839 dprintf(("sending to %s", inet_ntoa(((sockaddr_in*)to)->sin_addr))); 840 #ifdef DUMP_PACKETS 841 dprintf(("Packet length %d", len)); 842 for(int i=0;i<(len+7)/8;i++) { 843 dprintf(("%02x %02x %02x %02x %02x %02x %02x %02x %c %c %c %c %c %c %c %c", buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7], buf[i*8], buf[i*8+1], buf[i*8+2], buf[i*8+3], buf[i*8+4], buf[i*8+5], buf[i*8+6], buf[i*8+7])); 844 } 845 #endif 796 846 ret = sendto(s, (char *)buf, len, flags, (struct sockaddr *)to, tolen); 797 847 … … 1052 1102 return SOCKET_ERROR; 1053 1103 } 1104 dprintf(("IPPROTO_TCP, TCP_NODELAY 0x%x", *optval)); 1054 1105 ret = setsockopt(s, level, optname, (char *)optval, optlen); 1055 1106 }
Note:
See TracChangeset
for help on using the changeset viewer.