Exemple #1
0
        /// <inheritdoc />
        // ReSharper disable once InconsistentNaming
        public int ReceiveMessageFrom(byte[] buffer, int offset, int size, ref SocketFlags socketFlags, ref IEndPoint remoteEP, out IPPacketInformation ipPacketInformation)
        {
            var tempRemoteEp = remoteEP.ToImplementation();
            var result       = _socket.ReceiveMessageFrom(buffer, offset, size, ref socketFlags, ref tempRemoteEp, out ipPacketInformation);

            if (!ReferenceEquals(tempRemoteEp, remoteEP.ToImplementation()))
            {
                remoteEP = tempRemoteEp.ToInterface();
            }

            return(result);
        }
Exemple #2
0
        /// <inheritdoc />
        // ReSharper disable once InconsistentNaming
        public int ReceiveFrom(byte[] buffer, SocketFlags socketFlags, ref IEndPoint remoteEP)
        {
            var tempRemoteEp = remoteEP.ToImplementation();
            var result       = _socket.ReceiveFrom(buffer, socketFlags, ref tempRemoteEp);

            if (!ReferenceEquals(tempRemoteEp, remoteEP.ToImplementation()))
            {
                remoteEP = tempRemoteEp.ToInterface();
            }

            return(result);
        }
Exemple #3
0
 /// <inheritdoc />
 // ReSharper disable once InconsistentNaming
 public int SendTo(byte[] buffer, SocketFlags socketFlags, IEndPoint remoteEP)
 {
     return(_socket.SendTo(buffer, socketFlags, remoteEP.ToImplementation()));
 }
Exemple #4
0
 /// <inheritdoc />
 // ReSharper disable once InconsistentNaming
 public void Connect(IEndPoint remoteEP)
 {
     _socket.Connect(remoteEP.ToImplementation());
 }
Exemple #5
0
 /// <inheritdoc />
 // ReSharper disable once InconsistentNaming
 public void Bind(IEndPoint localEP)
 {
     _socket.Bind(localEP.ToImplementation());
 }
 /// <summary>
 /// Establishes a connection to a remote host.
 /// </summary>
 /// <param name="socket">The socket that is used for establishing a connection.</param>
 /// <param name="remoteEp">An EndPoint that represents the remote device.</param>
 /// <returns>An asynchronous Task.</returns>
 public static Task ConnectAsync(this ISocket socket, IEndPoint remoteEp)
 {
     return(socket.ToImplementation().ConnectAsync(remoteEp.ToImplementation()));
 }
 /// <summary>
 /// Sends data asynchronously to a specific remote host.
 /// </summary>
 /// <param name="socket">The socket to perform the operation on.</param>
 /// <param name="buffer">An array that contains the data to send.</param>
 /// <param name="socketFlags">A bitwise combination of the SocketFlags values.</param>
 /// <param name="remoteEp">An EndPoint that represents the remote device.</param>
 /// <returns>An asynchronous task that completes with number of bytes sent if the operation was successful. Otherwise, the task will complete with an invalid socket error.</returns>
 public static Task <int> SendToAsync(this ISocket socket, ArraySegment <byte> buffer, SocketFlags socketFlags, IEndPoint remoteEp)
 {
     return(socket.ToImplementation().SendToAsync(buffer, socketFlags, remoteEp.ToImplementation()));
 }
 /// <summary>
 /// Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.
 /// </summary>
 /// <param name="socket">The socket to perform the operation on.</param>
 /// <param name="buffer">An array that is the storage location for received data.</param>
 /// <param name="socketFlags">A bitwise combination of the SocketFlags values.</param>
 /// <param name="remoteEndPoint">An <see cref="EndPoint"/>, that represents the remote server.</param>
 /// <returns>An asynchronous Task that completes with a SocketReceiveMessageFromResult struct.</returns>
 public static Task <SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this ISocket socket, ArraySegment <byte> buffer, SocketFlags socketFlags, IEndPoint remoteEndPoint)
 {
     return(socket.ToImplementation().ReceiveMessageFromAsync(buffer, socketFlags, remoteEndPoint.ToImplementation()));
 }
 /// <summary>
 /// Establishes a connection to a remote host.
 /// </summary>
 /// <param name="socket">The socket that is used for establishing a connection.</param>
 /// <param name="remoteEp">An EndPoint that represents the remote device.</param>
 /// <param name="cancellationToken">Cancellation token.</param>
 /// <returns>An asynchronous Task.</returns>
 public static ValueTask ConnectAsync(this ISocket socket, IEndPoint remoteEp, CancellationToken cancellationToken)
 {
     return(socket.ToImplementation().ConnectAsync(remoteEp.ToImplementation(), cancellationToken));
 }