Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "socket" in [All]

httpapi

.

        // serialize the endpoint to a SocketAddress and create an array to hold the values.  Pin the array.

.

        SocketAddress socketAddress = ipEndPoint.Serialize();

.

        byte[] socketBytes = new byte[socketAddress.Size];

.

        GCHandle handleSocketAddress = GCHandle.Alloc(socketBytes, GCHandleType.Pinned);

.

        // Should copy the first 16 bytes (the SocketAddress has a 32 byte buffer, the size will only be 16,

.

        for (int i = 0; i < socketAddress.Size; ++i)

.

            socketBytes[i] = socketAddress[i];

.

        httpServiceConfigSslKey.pIpPort = handleSocketAddress.AddrOfPinnedObject();

.

        handleSocketAddress.Free();

Constants

.

        /// An attempt was made to access a socket in a way forbidden by its access permissions.

.

        /// Too many open sockets.

.

        /// A non-blocking socket operation could not be completed immediately.

.

        /// An operation was attempted on a non-blocking socket that already had an operation in progress.

.

        /// An operation was attempted on something that is not a socket.

.

        /// A required address was omitted from an operation on a socket.

.

        /// A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.

.

        /// A protocol was specified in the socket function call that does not support the semantics of the socket type requested.

.

        /// The support for the specified socket type does not exist in this address family.

.

        /// Only one usage of each socket address (protocol/network address/port) is normally permitted.

.

        /// A socket operation encountered a dead network.

.

        /// A socket operation was attempted to an unreachable network.

.

        /// An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.

.

        /// A connect request was made on an already connected socket.

.

        /// A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.

.

        /// A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.

.

        /// A socket operation failed because the destination host was down.

.

        /// A socket operation was attempted to an unreachable host.

.

        /// A Windows Sockets implementation may have a limit on the number of applications that may use it simultaneously.

.

        /// The Windows Sockets version requested is not supported.

iphlpapi

.

using System.Net.Sockets;

.

    public struct SOCKET_ADDRESS

.

        public SOCKET_ADDRESS Address;

.

        public SOCKET_ADDRESS Dhcpv4Server;

.

        public SOCKET_ADDRESS Dhcpv6Server;

.

            SOCKADDR socketAddr = (SOCKADDR)Marshal.PtrToStructure(unicastAddr.Address.lpSockAddr, typeof(SOCKADDR));

.

            byte[] saData = socketAddr.sa_data.Skip(2).Take(4).ToArray();

.

        catch (SocketException e)

.

        Console.WriteLine("SocketException caught!!!");

.

public const int AF_INET = 2;    // IP_v4 = System.Net.Sockets.AddressFamily.InterNetwork

.

public const int AF_INET6 = 23;  // IP_v6 = System.Net.Sockets.AddressFamily.InterNetworkV6

.

      public const int AF_INET = 2;    // IP_v4 = System.Net.Sockets.AddressFamily.InterNetwork

.

      public const int AF_INET6 = 23;  // IP_v6 = System.Net.Sockets.AddressFamily.InterNetworkV6

netapi32

.

public static extern int DsAddressToSiteNames(string computerName, int entryCount, SOCKET_ADDRESS[] socketAddresses, ref IntPtr siteNames);

.
  • entryCount: The number of elements in the socketAddresses array.
.
  • socketAddresses: An array of SOCKET_ADDRESS structures that contain the addresses to convert. Each address in this array must be of the type AF_INET. EntryCount contains the number of elements in this array.
.
  • siteNames: An array of null-terminated string pointers that contain the site names for the addresses. Each element in this array corresponds to the same element in the socketAddresses array. An element is NULL if the corresponding address does not map to any known site or if the address entry is not of the proper form. The caller must free this array when it is no longer required by calling NetApiBufferFree.
.

Prior to calling he DsAddressToSiteNames function, a SOCKET_ADDRESS structure must be created for each address that is to be resolved to a site name. This can be done using the WSAStringToAddress method shown in the sample code.

.

    SOCKET_ADDRESS[] SocketAddresses = new SOCKET_ADDRESS[1];

.

        // Call into WSAStringToAddress to build SOCKET_ADDRESS structure from the address string

.

            System.Net.Sockets.AddressFamily.InterNetwork,

.

        SocketAddresses[0].lpSockaddr = pSockAddr;

.

        SocketAddresses[0].iSockaddrLength = Marshal.SizeOf(sockAddr);

.

        result = DsAddressToSiteNames("domaincontroller.mydomain.com", 1, SocketAddresses, ref pSites);

.

     IntPtr SockAddresses, //must free this if using (SocketAddressCount > 1)

.

[out, optional] Pointer to a ULONG value that receives the number of elements in the SockAddresses array. If this parameter is NULL, socket addresses are not retrieved.

.

[out, optional] Pointer to an array of SOCKET_ADDRESS structures that receives the socket address data for the domain controller. SockAddressCount receives the number of elements in this array.

.

        using System.Net.Sockets;

Structures

.

        internal SOCKET_TYPE_INT ai_socktype;

.

                   ai_socktype = SOCKET_TYPE_INT.SOCK_STREAM,

.

SOCKET_TYPE_INT

11: AI
.

    /// The socket address will be used in a call to the bind function.

12: fd_set
.

        public static fd_set Create(IntPtr socket)

.

            fd_array = new IntPtr[Size] { socket }

.
Summary
.

        public uint SocketRegistersBaseAddress;

.
Summary
The SOCKET_ADDRESS structure stores protocol-specific address information.
.

    public struct SOCKET_ADDRESS

.

Structure SOCKET_ADDRESS

.
Documentation
[SOCKET_ADDRESS] on MSDN
.
Summary
The WSADATA structure contains information about the Windows Sockets implementation
.

        internal Int16 maxSockets;

.
Summary
The data returned from the Windows Socket API.

secur32

.

using System.Net.Sockets;

ws2_32

19: accept
.

        ByVal socketHandle As IntPtr, _

.

        ByRef socketAddress As sockaddr, _

.

System.Net.Sockets.Socket.Accept()

20: bind
.
Summary
The bind function associates a local address with a socket.
.
Remarks
The bind function is used on an unconnected socket before subsequent calls to the connect or listen functions. It is not neccessary to use bind for connect(), but is required for listen(). This binding process is performed by the connect() function implicitly. .
Parameter
.
Parameter
socketAddress A sockaddr_in structure used to identify the IP address and port to bind to.
.
Parameter
addressLength The length of the supplied socketAddress parameter.
.

        socketHandle As IntPtr, _

.

        ByRef socketAddress As sockaddr_in, _

.

/// Internet socket address structure.

.

public static bool Bind(string ipAddress, int port, IntPtr socketHandle)

.

    if (socketHandle != IntPtr.Zero)

.

            remoteAddress.sin_family = SocketsConstants.AF_INET;

.

                resultCode = bind(socketHandle, ref remoteAddress,

.

    public static extern int closesocket(IntPtr s);

.

Declare Function closesocket Lib "ws2_32.dll" (TODO) As TODO

.

static public void CloseSock(Socket sck)

.

    //you may add sck.Shutdown(SocketShutdown.Both);

.

    // to close the receiving and sending functions of the socket

.

    closesocket(sck.Handle);  

.
Documentation
[closesocket] on MSDN
.

    /// Use to determine the amount of data pending in the network's input buffer that can be read from socket s.

.

        /// Use to determine the amount of data pending in the network's input buffer that can be read from socket s.

.

    public static extern int getsockopt(IntPtr s, SocketOptionLevel level, SocketOptionName optname, out int optval, ref int optlen);

.

        Native.getsockopt(socketPtr, Native.SocketOptionLevel.Socket, Native.SocketOptionName.ReceiveTimeout, out optval, ref optlen);

.

        Native.setsockopt(socketPtr, Native.SocketOptionLevel.Socket, Native.SocketOptionName.ReceiveTimeout, ref optval, optlen);

.

    public static extern int ioctlsocket(IntPtr s, Command cmd, ref int argp);

.

Declare Function ioctlsocket Lib "ws2_32.dll" (TODO) As TODO

.

        //BufferRet = Native.recv(socketPtr, BufferPtr, Buffer, Native.MsgFlags.MSG_PEEK);

.

        //Native.ioctlsocket(this.socketPtr, Native.Command.FIONREAD, ref BufferRet);

.

            this.socketPtr, Native.ControlCode.FIONREAD,

.
Documentation
[ioctlsocket] on MSDN
26: recv
.

    public static extern int recvfrom(IntPtr Socket, IntPtr buf, int len, SendDataFlags flags, ref SockAddr from, IntPtr fromlen);

.

    public static int recvfrom(IntPtr Socket, IntPtr buf, int len, SendDataFlags flags, ref SockAddr from)

.

        return recvfrom(Socket, buf, len, flags, ref from, IntPtr.Zero);

27: select
.

        /* An optional pointer to a set of sockets to be checked for readability. */

.

        /* An optional pointer to a set of sockets to be checked for writability. */

.

        /* An optional pointer to a set of sockets to be checked for errors. */

28: send
.

public static extern int SendTo (IntPtr Socket, IntPtr buff, int len, SendDataFlags flags, ref SockAddr To, int tomlen);

.

    /// <summary>    Specifies that the data should not be subject to routing. A Windows Sockets service provider can choose to ignore this flag</summary>

.

    /// <summary>Sends OOB data (stream-style socket such as SOCK_STREAM only)</summary>

.

System.Net.Sockets.Socket (class) Socket.SendTo () - better to use It))

.

If no error occurs, sendto returns the total number of bytes sent, which can be less than the number indicated by len. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

29: SendTo
.

public static extern int SendTo (IntPtr Socket, IntPtr buff, int len, SendDataFlags flags, ref SockAddr To, int tomlen);

.

    /// <summary>    Specifies that the data should not be subject to routing. A Windows Sockets service provider can choose to ignore this flag</summary>

.

    /// <summary>Sends OOB data (stream-style socket such as SOCK_STREAM only)</summary>

.

System.Net.Sockets.Socket (class) Socket.SendTo () - better to use It))

.

If no error occurs, sendto returns the total number of bytes sent, which can be less than the number indicated by len. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

.

    public static extern int setsockopt(IntPtr s, SocketOptionLevel level, SocketOptionName optname, ref int optval, int optlen);

.

        Native.getsockopt(socketPtr, Native.SocketOptionLevel.Socket, Native.SocketOptionName.ReceiveTimeout, out optval, ref optlen);

.

        Native.setsockopt(socketPtr, Native.SocketOptionLevel.Socket, Native.SocketOptionName.ReceiveTimeout, ref optval, optlen);

31: socket
.

    public enum SOCKET_TYPE : short

.

    /// stream socket

.

    /// datagram socket

.
Documentation
[SOCKET_TYPE] on MSDN
.

    public enum SocketOptionLevel

.

        Socket = 0xffff,

.
Documentation
[SocketOptionLevel] on MSDN
.

    public enum SocketOptionName

.
Documentation
[SocketOptionName] on MSDN
.

    public enum SOCKET_OPTION_NAME : int    

.

        #region IPPROTO_IP Socket Options

.

        #region IPPROTO_IPV6 Socket Options

.

        /// Offset to checksum for raw IP socket send.

.

        #region SOL_SOCKET Socket Options

.

        /// socket has had listen()

.

        /// get socket type

.

        /// get socket 5-tuple state

.

        /// ID of a socket group

.

        /// get/set the compartment for a socket

.

        /// Option for opening sockets for synchronous access.

.

        #region IPPROTO_TCP Socket Options

.

        /// Enables or disables the Nagle algorithm for TCP sockets. This option is disabled (set to FALSE) by default.

.

        /// Enables or disables the Nagle algorithm for TCP sockets. This option is disabled (set to FALSE) by default.

.

        #region IPPROTO_UDP Socket Options

.
Documentation
[SOCKET_OPTION_NAME] on MSDN
.
Summary
Cleans up the Windows Sockets resources. Ensure this method is called after every successful call to WSAStartup().
.
Summary
Data structure for the Windows Socket API
.

    public Int16 maxSockets;

.

    internal ushort iMaxSockets;

.

        /* Socket, Mode */

.

        IntPtr s, System.Net.Sockets.IOControlCode dwIoControlCode,

.

        //BufferRet = Native.recv(socketPtr, BufferPtr, Buffer, Native.MsgFlags.MSG_PEEK);

.

        //Native.ioctlsocket(this.socketPtr, Native.Command.FIONREAD, ref BufferRet);

.

            this.socketPtr, Native.ControlCode.FIONREAD,

.

        if (WSALookupServiceBegin(ref lpRestrictions, 4080, ref hLookup) != (int)SocketError.SocketError)

.

[Socket.IOControl] on MSDN

.

    public int iSocketType;

.
Summary
The WSASocket function creates a socket that is bound to a specific transport-service provider.
.

  public static extern IntPtr WSASocket(ADDRESS_FAMILIES af, SOCKET_TYPE socket_type, PROTOCOL protocol,

.

        IntPtr lpProtocolInfo, Int32 group, OPTION_FLAGS_PER_SOCKET dwFlags);

.

Declare Function WSASocket Lib "ws2_32.dll" (TODO) As TODO

.

    public enum SOCKET_TYPE : short

.

        /// stream socket

.

        /// datagram socket

.

    public enum OPTION_FLAGS_PER_SOCKET : short

.

        // socket has had listen()  

.

        // get socket type  

.

        // ID of a socket group  

.
Summary
The WSAStringToAddress function converts a network address in its standard text presentation form into its numeric binary form in a sockaddr structure, suitable for passing to Windows Sockets routines that take such a structure.
.
  • socketAddress: A pointer to a buffer that is filled with a sockaddr structure for the address string if the function succeeds.
.
  • socketAddressSize: A pointer to the length, in bytes, of the buffer pointed to by the lpAddress parameter.
.

        System.Net.Sockets.AddressFamily.InterNetwork,

dnsapi

.

    using System.Net.Sockets;

.

    using System.Net.Sockets;

Enums

.

    internal enum SOCKET_TYPE_INT : int

.

        /// stream socket

.

        /// datagram socket

.

Enum SOCKET_TYPE_INT

.
Documentation
[SOCKET_TYPE_INT] on MSDN

wininet

.

phFtpCommand (out) A pointer to a handle that is created if a valid data socket is opened. The fExpectResponse parameter must be set to TRUE for phFtpCommand to be filled.

Interfaces

.

    // hence the read goes directly to e.g. socket


 
Access PInvoke.net directly from VS: