Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
3.2 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. // Inlines for AFXSOCK.H
  11. #ifdef _AFXSOCK_INLINE
  12. _AFXSOCK_INLINE CAsyncSocket::operator SOCKET() const
  13. { return m_hSocket; }
  14. _AFXSOCK_INLINE BOOL CAsyncSocket::GetPeerName(SOCKADDR* lpSockAddr, int* lpSockAddrLen)
  15. { return (SOCKET_ERROR != getpeername(m_hSocket, lpSockAddr, lpSockAddrLen)); }
  16. _AFXSOCK_INLINE BOOL CAsyncSocket::GetSockName(SOCKADDR* lpSockAddr, int* lpSockAddrLen)
  17. { return (SOCKET_ERROR != getsockname(m_hSocket, lpSockAddr, lpSockAddrLen)); }
  18. _AFXSOCK_INLINE BOOL CAsyncSocket::SetSockOpt(int nOptionName, const void* lpOptionValue, int nOptionLen, int nLevel)
  19. { return (SOCKET_ERROR != setsockopt(m_hSocket, nLevel, nOptionName, (LPCSTR)lpOptionValue, nOptionLen)); }
  20. _AFXSOCK_INLINE BOOL CAsyncSocket::GetSockOpt(int nOptionName, void* lpOptionValue, int* lpOptionLen, int nLevel)
  21. { return (SOCKET_ERROR != getsockopt(m_hSocket, nLevel, nOptionName, (LPSTR)lpOptionValue, lpOptionLen)); }
  22. _AFXSOCK_INLINE CAsyncSocket* PASCAL CAsyncSocket::FromHandle(SOCKET hSocket)
  23. { return CAsyncSocket::LookupHandle(hSocket, FALSE); }
  24. _AFXSOCK_INLINE int PASCAL CAsyncSocket::GetLastError()
  25. { return WSAGetLastError(); }
  26. _AFXSOCK_INLINE BOOL CAsyncSocket::Bind(const SOCKADDR* lpSockAddr, int nSockAddrLen)
  27. { return (SOCKET_ERROR != bind(m_hSocket, lpSockAddr, nSockAddrLen)); }
  28. _AFXSOCK_INLINE BOOL CAsyncSocket::Connect(const SOCKADDR* lpSockAddr, int nSockAddrLen)
  29. { return ConnectHelper(lpSockAddr, nSockAddrLen); }
  30. _AFXSOCK_INLINE BOOL CAsyncSocket::IOCtl(long lCommand, DWORD* lpArgument)
  31. { return (SOCKET_ERROR != ioctlsocket(m_hSocket, lCommand, lpArgument)); }
  32. _AFXSOCK_INLINE BOOL CAsyncSocket::Listen(int nConnectionBacklog)
  33. { return (SOCKET_ERROR != listen(m_hSocket, nConnectionBacklog)); }
  34. _AFXSOCK_INLINE int CAsyncSocket::ReceiveFrom(void* lpBuf, int nBufLen, SOCKADDR* lpSockAddr, int* lpSockAddrLen, int nFlags)
  35. { return ReceiveFromHelper(lpBuf, nBufLen, lpSockAddr, lpSockAddrLen, nFlags); }
  36. _AFXSOCK_INLINE BOOL CAsyncSocket::ShutDown(int nHow)
  37. { return (SOCKET_ERROR != shutdown(m_hSocket,nHow)); }
  38. _AFXSOCK_INLINE int CAsyncSocket::SendTo(const void* lpBuf, int nBufLen, const SOCKADDR* lpSockAddr, int nSockAddrLen, int nFlags)
  39. { return SendToHelper(lpBuf, nBufLen, lpSockAddr, nSockAddrLen, nFlags); }
  40. _AFXSOCK_INLINE BOOL CSocket::Create(UINT nSocketPort, int nSocketType, LPCTSTR lpszSocketAddress)
  41. { return CAsyncSocket::Create(nSocketPort, nSocketType, FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE, lpszSocketAddress); }
  42. _AFXSOCK_INLINE BOOL CSocket::IsBlocking()
  43. { return (m_pbBlocking != NULL); }
  44. _AFXSOCK_INLINE CSocket* PASCAL CSocket::FromHandle(SOCKET hSocket)
  45. { return (CSocket*)CAsyncSocket::LookupHandle(hSocket, FALSE); }
  46. _AFXSOCK_INLINE BOOL CSocket::Attach(SOCKET hSocket)
  47. { return CAsyncSocket::Attach(hSocket); }
  48. #endif //_AFXSOCK_INLINE