Changeset 1372 for trunk/src


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

Fix: WSA async rewrite

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:28 phaller Exp $ */
     1/* $Id: async.cpp,v 1.2 1999-10-20 10:03:52 phaller Exp $ */
    22
    33/*
     
    2323#include <odinwrap.h>
    2424#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
    2738#include <misc.h>
     39
     40
     41/*****************************************************************************
     42 * Definitions                                                               *
     43 *****************************************************************************/
     44
     45ODINDEBUGCHANNEL(WSOCK32-ASYNC)
     46
    2847
    2948
     
    7392  ULONG  ul2;
    7493  ULONG  ul3;
    75   ULONG  ul4;
    76   ULONG  ul5;
    7794
    7895} ASYNCREQUEST, *PASYNCREQUEST;
    7996
    8097
     98/*****************************************************************************
     99 * Prototypes                                                                *
     100 *****************************************************************************/
     101
     102void _Optlink WorkerThreadProc(void* pParam);
     103BOOL _System PostMessageA(HWND hwnd, UINT ulMessage, WPARAM wParam, LPARAM lParam);
     104
     105void _System SetLastError(int iError);
     106int  _System GetLastError(void);
     107#define WSASetLastError(a) SetLastError(a)
     108
    81109
    82110/*****************************************************************************
     
    86114class WSAAsyncWorker
    87115{
    88   // private members
    89   PASYNCREQUEST pRequestHead = NULL; // chain root
    90   PASYNCREQUEST pRequestTail = NULL; // chain root
    91   TID           tidWorker    = 0;    // worker thread id
    92   HEV           hevRequest;          // fired upon new request
    93   HMUTEX        hmtxRequestQueue;    // request queue protection
    94 
    95116  // public members
    96117  public:
     
    98119    ~WSAAsyncWorker();                            // destructor
    99120
    100     PASYNCREQUEST createRequest  (HWND  hwnd,
     121    PASYNCREQUEST createRequest  (ULONG ulType,
     122                                  HWND  hwnd,
    101123                                  ULONG ulMessage,
     124                                  PVOID pBuffer,
     125                                  ULONG ulBufferLength,
    102126                                  ULONG ul1 = 0,
    103127                                  ULONG ul2 = 0,
    104                                   ULONG ul3 = 0,
    105                                   ULONG ul4 = 0,
    106                                   ULONG ul5 = 0);
     128                                  ULONG ul3 = 0);
     129
    107130    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);
    109135
    110136
    111137  // protected members
    112138  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 ?
    114145
    115146    TID           startWorker    (void);                   // start worker thread
     
    117148    int           dispatchRequest(PASYNCREQUEST pRequest); // complete request
    118149    PASYNCREQUEST popRequest     (void);                   // get one request from queue
    119     BOOL          deleteRequest  (PASYNCREQUEST pRequest); // remove particular request
    120150
    121151    void          lockQueue      (void);                   // enter mutex
     
    132162
    133163
     164/*****************************************************************************
     165 * Local variables                                                           *
     166 *****************************************************************************/
     167
     168static 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 *****************************************************************************/
    134182// constructor
    135183WSAAsyncWorker::WSAAsyncWorker(void)
    136184{
     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
    137192  startWorker();
    138193}
    139194
    140195
     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 *****************************************************************************/
    141207// destructor
    142208WSAAsyncWorker::~WSAAsyncWorker(void)
    143209{
     210  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::~WSAAsyncWorker (%08xh)\n",
     211           this));
     212
    144213  // remove all requests
    145214  while (popRequest() != NULL);
     
    158227
    159228
     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 *****************************************************************************/
    160240// start worker thread if necessary
    161241TID WSAAsyncWorker::startWorker(void)
    162242{
    163243  APIRET rc;
     244
     245  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::startWorker (%08xh)\n",
     246           this));
    164247
    165248  if (tidWorker == 0)
     
    192275
    193276    // create thread
     277#if defined(__IBMCPP__)
     278    tidWorker = _beginthread(WorkerThreadProc,
     279                             (PVOID)this,
     280                             4096,
     281                             NULL);
     282#else
    194283    tidWorker = _beginthread(WorkerThreadProc,
    195284                             (PVOID)this,
    196285                             4096);
     286#endif
    197287    if (tidWorker == -1)
    198288    {
     
    208298
    209299
     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 *****************************************************************************/
    210311// lock double-linked request chain
    211312void WSAAsyncWorker::lockQueue(void)
    212313{
    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 *****************************************************************************/
    217329// unlock double-linked request chain
    218330void WSAAsyncWorker::unlockQueue(void)
    219331{
    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 *****************************************************************************/
    224347// get request from queue
    225348PASYNCREQUEST WSAAsyncWorker::popRequest(void)
     
    245368
    246369
     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 *****************************************************************************/
    247381// insert request into queue
    248382void WSAAsyncWorker::pushRequest(PASYNCREQUEST pNew)
     
    275409
    276410
     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 *****************************************************************************/
    277422// delete particular request from queue
    278423BOOL WSAAsyncWorker::deleteRequest(PASYNCREQUEST pDelete)
     
    321466        }
    322467
     468    delete pDelete; // free the memory
    323469    bResult = TRUE; // OK
    324470  }
     
    329475
    330476
     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
     489PASYNCREQUEST 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 *****************************************************************************/
    331528
    332529void WSAAsyncWorker::asyncGetHostByAddr   (PASYNCREQUEST pRequest)
     
    338535  USHORT          rc;
    339536
     537  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByAddr (%08xh, %08xh)\n",
     538           this,
     539           pRequest));
     540
    340541  // result buffer length
    341542  usLength = min(pRequest->ulBufferLength, sizeof(struct hostent));
    342543
    343544  // call API
    344   pHostent = gethostbyaddr((const char*)pRequest->u1,
    345                            (int)        pRequest->u2,
    346                            (int)        pRequest->u3);
     545  pHostent = gethostbyaddr((const char*)pRequest->ul1,
     546                           (int)        pRequest->ul2,
     547                           (int)        pRequest->ul3);
    347548  if (pHostent == NULL) // error ?
    348549  {
     
    368569}
    369570
     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
    370584void WSAAsyncWorker::asyncGetHostByName   (PASYNCREQUEST pRequest)
    371585{
     
    376590  USHORT          rc;
    377591
     592  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetHostByName (%08xh, %08xh)\n",
     593           this,
     594           pRequest));
     595
    378596  // result buffer length
    379597  usLength = min(pRequest->ulBufferLength, sizeof(struct hostent));
    380598
    381599  // call API
    382   pHostent = gethostbyname((const char*)pRequest->u1);
     600  pHostent = gethostbyname((const char*)pRequest->ul1);
    383601  if (pHostent == NULL) // error ?
    384602  {
     
    405623
    406624
     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
    407637void WSAAsyncWorker::asyncGetProtoByName  (PASYNCREQUEST pRequest)
    408638{
     
    413643  USHORT           rc;
    414644
     645  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByName (%08xh, %08xh)\n",
     646           this,
     647           pRequest));
     648
    415649  // result buffer length
    416650  usLength = min(pRequest->ulBufferLength, sizeof(struct protoent));
    417651
    418652  // call API
    419   pProtoent = getprotobyname((const char*)pRequest->u1);
     653  pProtoent = getprotobyname((const char*)pRequest->ul1);
    420654  if (pProtoent == NULL) // error ?
    421655  {
     
    441675}
    442676
     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
    443690void WSAAsyncWorker::asyncGetProtoByNumber(PASYNCREQUEST pRequest)
    444691{
     
    449696  USHORT           rc;
    450697
     698  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetProtoByNumber (%08xh, %08xh)\n",
     699           this,
     700           pRequest));
     701
    451702  // result buffer length
    452703  usLength = min(pRequest->ulBufferLength, sizeof(struct protoent));
    453704
    454705  // call API
    455   pProtoent = getprotobyname((int)pRequest->u1);
     706  pProtoent = getprotobyname((const char*)pRequest->ul1);
    456707  if (pProtoent == NULL) // error ?
    457708  {
     
    478729
    479730
     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
    480743void WSAAsyncWorker::asyncGetServByName(PASYNCREQUEST pRequest)
    481744{
     
    486749  USHORT          rc;
    487750
     751  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByName (%08xh, %08xh)\n",
     752           this,
     753           pRequest));
     754
    488755  // result buffer length
    489756  usLength = min(pRequest->ulBufferLength, sizeof(struct servent));
    490757
    491758  // call API
    492   pServent = getservbyname((const char*)pRequest->u1,
    493                            (const char*)pRequest->u2);
     759  pServent = getservbyname((const char*)pRequest->ul1,
     760                           (const char*)pRequest->ul2);
    494761  if (pServent == NULL) // error ?
    495762  {
     
    516783
    517784
     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
    518797void WSAAsyncWorker::asyncGetServByPort(PASYNCREQUEST pRequest)
    519798{
     
    524803  USHORT          rc;
    525804
     805  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::asyncGetServByPort (%08xh, %08xh)\n",
     806           this,
     807           pRequest));
     808
    526809  // result buffer length
    527810  usLength = min(pRequest->ulBufferLength, sizeof(struct servent));
    528811
    529812  // call API
    530   pServent = getservbyport((int        )pRequest->u1,
    531                            (const char*)pRequest->u2);
     813  pServent = getservbyport((int        )pRequest->ul1,
     814                           (const char*)pRequest->ul2);
    532815  if (pServent == NULL) // error ?
    533816  {
     
    554837
    555838
     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 *****************************************************************************/
    556850// process one request
    557851int WSAAsyncWorker::dispatchRequest(PASYNCREQUEST pRequest)
    558852{
     853  dprintf(("WSOCK32-ASYNC: WSAAsyncWorker::dispatchRequest (%08xh, %08xh)\n",
     854           this,
     855           pRequest));
     856
    559857  // check request state first
    560858  switch(pRequest->ulState)
     
    574872
    575873  // OK, servicing request
    576   pRequest->ulStatus = RS_BUSY;
     874  pRequest->ulState = RS_BUSY;
    577875
    578876  switch(pRequest->ulType)
     
    582880      return 1;
    583881
    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;
    638891
    639892    default:
     
    643896  }
    644897
    645   pRequest->ulStatus = RS_DONE;
     898  pRequest->ulState = RS_DONE;
    646899  return 0;
    647900}
    648901
    649902
     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 *****************************************************************************/
    650914// process all requests in queue until termination
    651915void WSAAsyncWorker::processingLoop(void)
     
    662926      pRequest = popRequest();     // get request from queue
    663927      if (pRequest != NULL)
     928      {
    664929        dispatchRequest(pRequest); // process request
     930        delete pRequest;           // free the memory
     931      }
    665932    }
    666     while (pRequest != NULL)
     933    while (pRequest != NULL);
    667934
    668935    // wait for semaphore
     
    676943
    677944
     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 *****************************************************************************/
    678956// thread procedure
    679 void _System WorkerThreadProc(PVOID pParam)
     957void _Optlink WorkerThreadProc(void* pParam)
    680958{
    681959  // convert object pointer
     
    685963
    686964
     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 *****************************************************************************/
    687976// the real function calls
    688977ODINFUNCTION5(HANDLE, WSAAsyncGetHostByName, HWND,         hwnd,
     
    692981                                             int,          buflen)
    693982{
    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,
    695987                                                    (PVOID)buf,
    696988                                                    (ULONG)buflen,
    697                                                     (ULONG)wMsg,
    698989                                                    (ULONG)name);
    699990  wsaWorker->pushRequest(pRequest);
     
    702993
    703994
     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
     1007ODINFUNCTION7(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
     1040ODINFUNCTION6(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
     1072ODINFUNCTION6(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
     1104ODINFUNCTION5(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
     1134ODINFUNCTION5(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
     1163ODINFUNCTION1(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 sandervl Exp $
     1# $Id: makefile,v 1.9 1999-10-20 10:03:53 phaller Exp $
    22
    33#
     
    2121TARGET = wsock32
    2222
    23 OBJS =  wsock32.obj notify.obj initterm.obj unknown.obj
     23OBJS =  wsock32.obj notify.obj initterm.obj unknown.obj async.obj
    2424
    2525all: $(TARGET).dll $(TARGET).lib
     
    4040        $(IMPDEF) $** $@
    4141
    42 wsock32.obj: wsock32.cpp wsock32.h
     42wsock32.obj: wsock32.cpp wsock32.h wsock32const.h
    4343notify.obj:  notify.cpp wsock32.h
    4444unknown.obj: unknown.cpp wsock32.h
     45async.obj:   async.cpp wsock32const.h
    4546initterm.obj: initterm.cpp
    4647
  • trunk/src/wsock32/wsock32.cpp

    r1367 r1372  
    1 /* $Id: wsock32.cpp,v 1.5 1999-10-20 01:18:31 phaller Exp $ */
     1/* $Id: wsock32.cpp,v 1.6 1999-10-20 10:03:53 phaller Exp $ */
    22
    33/*
     
    5555#include <sys/time.h>
    5656#include <win32type.h>
     57#include "wsock32const.h"
    5758#include "wsock32.h"
    5859#include "misc.h"
     
    14821483
    14831484
    1484 // The following 6 calls need to start a new thread, perform
    1485 // the operation, copy ALL the info to the buffer provided then
    1486 // notify the sender.
    1487 
    1488 /*****************************************************************************
    1489  * Name      :
    1490  * Purpose   :
    1491  * Parameters:
    1492  * Variables :
    1493  * Result    :
    1494  * Remark    :
    1495  * Status    : UNTESTED STUB
    1496  *
    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 STUB
    1570  *
    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 STUB
    1595  *
    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 STUB
    1618  *
    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 STUB
    1641  *
    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 STUB
    1664  *
    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 STUB
    1690  *
    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   else
    1705     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 switch
    1721 
    1722   OS2WSASetLastError(rc);
    1723   return SOCKET_ERROR; // ERROR!
    1724 }
    1725 
    1726 
    17271485/*****************************************************************************
    17281486 * Name      :
  • trunk/src/wsock32/wsock32.def

    r283 r1372  
    1 ; $Id: wsock32.def,v 1.5 1999-07-07 12:18:04 phaller Exp $
     1; $Id: wsock32.def,v 1.6 1999-10-20 10:03:53 phaller Exp $
    22
    33;Created by BLAST for IBM's compiler
    44LIBRARY WSOCK32 INITINSTANCE
    55DATA MULTIPLE NONSHARED
     6
     7IMPORTS
     8    PostMessageA           = USER32.416
     9    SetLastError           = KERNEL32.654
     10    GetLastError           = KERNEL32.340
     11
     12
    613EXPORTS
    714;   _WSAFDIsSet =       _OS2_WSAFDIsSet@8
     
    5461   gethostname =               _OS2gethostname@8                       @57
    5562
    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
    6473   WSASetBlockingHook =      _OS2WSASetBlockingHook@4                  @109
    6574   WSAUnhookBlockingHook =   _OS2WSAUnhookBlockingHook@0       @110
  • trunk/src/wsock32/wsock32.h

    r518 r1372  
    1 /* $Id: wsock32.h,v 1.4 1999-08-16 20:18:40 phaller Exp $ */
     1/* $Id: wsock32.h,v 1.5 1999-10-20 10:03:54 phaller Exp $ */
    22
    33/* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
     
    400400 */
    401401
    402 /*
    403  * This is used instead of -1, since the
    404  * SOCKET type is unsigned.
    405  */
    406 #define INVALID_SOCKET  (SOCKET)(~0)
    407 #define SOCKET_ERROR            (-1)
    408402
    409403/*
     
    561555#define FD_CONNECT      0x10
    562556#define FD_CLOSE        0x20
    563 
    564 /*
    565  * All Windows Sockets error constants are biased by WSABASEERR from
    566  * the "normal"
    567  */
    568 #define WSABASEERR              10000
    569 /*
    570  * Windows Sockets definitions of regular Microsoft C error constants
    571  */
    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 constants
    581  */
    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 definitions
    624  */
    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 are
    632  * retrieved via WSAGetLastError() and must therefore follow
    633  * the rules for avoiding clashes with error numbers from
    634  * 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 for
    637  * 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_FOUND
    645 
    646 /* Non-Authoritative: Host not found, or SERVERFAIL */
    647 #define WSATRY_AGAIN            (WSABASEERR+1002)
    648 #define WTRY_AGAIN               WSATRY_AGAIN
    649 
    650 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
    651 #define WSANO_RECOVERY          (WSABASEERR+1003)
    652 #define WNO_RECOVERY             WSANO_RECOVERY
    653 
    654 /* Valid name, no data record of requested type */
    655 #define WSANO_DATA              (WSABASEERR+1004)
    656 #define WNO_DATA                 WSANO_DATA
    657 
    658 /* no address, look for MX record */
    659 #define WSANO_ADDRESS           WSANO_DATA
    660 #define WNO_ADDRESS              WSANO_ADDRESS
    661557
    662558
Note: See TracChangeset for help on using the changeset viewer.