Ignore:
Timestamp:
Oct 20, 1999, 10:11:03 PM (26 years ago)
Author:
phaller
Message:

Fix: socket fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wsock32/async.cpp

    r1374 r1384  
    1 /* $Id: async.cpp,v 1.4 1999-10-20 11:04:12 phaller Exp $ */
     1/* $Id: async.cpp,v 1.5 1999-10-20 20:10:55 phaller Exp $ */
    22
    33/*
     
    3030#include <nerrno.h>
    3131#include <sys/socket.h>
     32#include <sys/ioctl.h>
     33#include <sys/select.h>
     34#include <unistd.h>
     35
    3236#include <wsock32const.h>
    3337
     
    140144    void          asyncGetServByName   (PASYNCREQUEST pRequest);
    141145    void          asyncGetServByPort   (PASYNCREQUEST pRequest);
     146    void          asyncSelect          (PASYNCREQUEST pRequest);
    142147
    143148  // public members
     
    595600  struct hostent* pHostent;
    596601  USHORT          usLength;
    597   ULONG           wParam;
    598   ULONG           lParam;
    599602  USHORT          rc;
    600603
     
    650653  struct hostent* pHostent;
    651654  USHORT          usLength;
    652   ULONG           wParam;
    653   ULONG           lParam;
    654655  USHORT          rc;
    655656
     
    703704  struct protoent* pProtoent;
    704705  USHORT           usLength;
    705   ULONG            wParam;
    706   ULONG            lParam;
    707706  USHORT           rc;
    708707
     
    756755  struct protoent* pProtoent;
    757756  USHORT           usLength;
    758   ULONG            wParam;
    759   ULONG            lParam;
    760757  USHORT           rc;
    761758
     
    809806  struct servent* pServent;
    810807  USHORT          usLength;
    811   ULONG           wParam;
    812   ULONG           lParam;
    813808  USHORT          rc;
    814809
     
    863858  struct servent* pServent;
    864859  USHORT          usLength;
    865   ULONG           wParam;
    866   ULONG           lParam;
    867860  USHORT          rc;
    868861
     
    899892  // M$ says, if PostMessageA fails, spin as long as window exists
    900893}
     894
     895
     896
     897/*****************************************************************************
     898 * Name      : WSAAsyncWorker::asyncSelect
     899 * Purpose   :
     900 * Parameters:
     901 * Variables :
     902 * Result    :
     903 * Remark    :
     904 * Status    : UNTESTED
     905 *
     906 * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     907 *****************************************************************************/
     908
     909typedef int SOCKET;
     910
     911void WSAAsyncWorker::asyncSelect(PASYNCREQUEST pRequest)
     912{
     913  ULONG           wParam;
     914  ULONG           lParam;
     915  int             irc;
     916  int             iUnknown;
     917
     918  SOCKET          sockWin;
     919  ULONG           ulEvent;
     920  USHORT          usResult = 0;
     921
     922  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncSelect (%08xh, %08xh) not correctly implemented\n",
     923           this,
     924           pRequest));
     925
     926
     927  // setup variables
     928  sockWin = (SOCKET)pRequest->ul1;
     929  ulEvent = (ULONG) pRequest->ul2;
     930
     931  //@@@PH how to implement other events?
     932
     933  // finally do the select!
     934  irc = os2_select(&sockWin,
     935                   (ulEvent & FD_READ),
     936                   (ulEvent & FD_WRITE),
     937                   (ulEvent & FD_OOB),
     938                   10000);              // @@@PH timeout
     939  if (irc < 0)                                          /* an error occurred */
     940  {
     941    lParam = sock_errno();                          /* raise error condition */
     942    if (lParam == SOCENOTSOCK)
     943    {
     944      usResult = FD_CLOSE;
     945      lParam   = 0;
     946    }
     947  }
     948  else
     949    if (irc == 0)                                      /* this means timeout */
     950    {
     951      lParam = WSAETIMEDOUT;                        /* raise error condition */
     952    }
     953    else
     954    {
     955      //@@@PH check the socket for any event and report!
     956      usResult = 0;
     957
     958      // readiness for reading bytes ?
     959      irc = ioctl(sockWin, FIONREAD, &iUnknown, sizeof(iUnknown));
     960      if ( (irc == 0) && (iUnknown > 0))
     961         usResult |= FD_READ;
     962    }
     963
     964  // post result
     965  PostMessageA(pRequest->hwnd,
     966               pRequest->ulMessage,
     967               (WPARAM)sockWin,
     968               (LPARAM)((lParam << 16) | usResult));
     969
     970  // M$ says, if PostMessageA fails, spin as long as window exists
     971}
     972
    901973
    902974
     
    12621334  return(wsaWorker->isBlocking());
    12631335}
     1336
     1337
     1338/*****************************************************************************
     1339 * Name      :
     1340 * Purpose   :
     1341 * Parameters:
     1342 * Variables :
     1343 * Result    :
     1344 * Remark    :
     1345 * Status    : UNTESTED STUB
     1346 *
     1347 * Author    : Patrick Haller [Tue, 1998/06/16 23:00]
     1348 *****************************************************************************/
     1349// the real function calls
     1350ODINFUNCTION4(HANDLE, WSAAsyncSelect,SOCKET,       s,
     1351                                     HWND,         hwnd,
     1352                                     unsigned int, wMsg,
     1353                                     long,         lEvent)
     1354{
     1355  PASYNCREQUEST pRequest = wsaWorker->createRequest(WSAASYNC_SELECT,
     1356                                                    (HWND) hwnd,
     1357                                                    (ULONG)wMsg,
     1358                                                    (PVOID)NULL,
     1359                                                    (ULONG)0,
     1360                                                    (ULONG)s,
     1361                                                    (ULONG)lEvent);
     1362  wsaWorker->pushRequest(pRequest);
     1363  return (HANDLE)pRequest;
     1364}
     1365
Note: See TracChangeset for help on using the changeset viewer.