BugInTheSYS

C# Winsock2.h function translation error

Nov 21st, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. //C++ Source
  2.  
  3. WINSOCK_API_LINKAGE
  4. int
  5. WSAAPI
  6. getpeername(
  7.     __in SOCKET s,
  8.     __out_bcount_part(*namelen,*namelen) struct sockaddr FAR * name,
  9.     __inout int FAR * namelen
  10.     )
  11.  
  12. //C# Translation
  13.  
  14. /// <summary>
  15.     /// The getpeername function retrieves the address of the peer to which a socket is connected.
  16.     /// </summary>
  17.     /// <param name="s">A descriptor identifying a connected socket.</param>
  18.     /// <param name="name">The SOCKADDR structure that receives the address of the peer.</param>
  19.     /// <param name="namelen">A pointer to the size, in bytes, of the name parameter.</param>
  20.     /// <returns>If no error occurs, getpeername returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.</returns>
  21.     /// <remarks>http://msdn.microsoft.com/en-us/library/windows/desktop/ms738533%28v=VS.85%29.aspx</remarks>
  22.   [System.Runtime.InteropServices.DllImportAttribute("ws2_32.dll", EntryPoint="getpeername", CallingConvention=System.Runtime.InteropServices.CallingConvention.StdCall)]
  23.   public static extern  int getpeername([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.SysUInt)] uint s, System.IntPtr name, ref int namelen) ;
  24.  
  25. //C# error
  26. Error 1 "Expected Class, Delegate, Enum, Interface or Struct."
  27.  
Advertisement
Add Comment
Please, Sign In to add comment