Wsasendto function

When to Perform a Winsock Reset

If you can’t view any web pages despite having a stable Wi-Fi connection, resetting Winsock could fix the problem. A Winsock reset can be helpful if you’re having internet connection problems in these situations:

  • After removing malware
  • When you’re seeing network-related pop-up errors
  • When there are DNS lookup issues
  • When you’ve just uninstalled network-related software like a firewall program or VPN
  • When you see ”limited or no connectivity” errors
  • When releasing and renewing the IP address doesn’t restore connectivity
  • When the internet works on other devices on the same network but not on your Windows PC

A netsh Winsock reset will break functionality in some programs, so you might end up having to reconfigure some of your software to make them work normally again.

AFD-Initiated Abort

Event ID = 7

Level = 4 (Information)

The following Winsock events are traced for Winsock-initiated aborts or cancel operations:

  • An abort due to unread receive data buffered after close.
  • An abort after a call to the shutdown function with the how parameter set to SD_RECEIVE and a call to the closesocket function with receive data pending.
  • An abort after a failed attempt to flush the endpoint.
  • An abort after an internal Winsock error occurred.
  • An abort due to a connection with errors and the application previously requested that the connection be aborted on certain circumstances. One example of this case would be an application that set SO_LINGER with a timeout of zero and there is still unacknowledged data on the connection.
  • An abort on a connection not fully associated with accepting endpoint.
  • An abort on a failed call to the accept or AcceptEx function.
  • An abort due to a failed receive operation.
  • An abort due to a Plug and Play event.
  • An abort due to a failed flush request.
  • An abort due to a failed expedited data receive request.
  • An abort due to a failed send request.
  • An abort due to canceled send request.
  • An abort due to a canceled called to the TransmitPackets function.

The following parameters are logged for a Winsock-initiated abort or cancel operation:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
Reason The reason for the abort or cancel operation.

WinSock 2 Status

For the status of specific WinSock 2 features, see the WinSock
2 Feature Status
page. Here is a summary:

  • WinSock 2 SDK: Sept ’98 as part of Microsoft’s «Platform
    SDK» available on-line through MSDN. Download.
  • Add-on for Windows 95: Equivalent to Win98 version, but lacks
    GQOS support. Download
    (look for»Windows Socket 2 Update»).
  • Native in Windows 98: It includes support for the «Generic
    QOS APIs» (RSVP support only)
  • Native in Windows NT4: Substantial updates available
    in Service Pack 4 (SP4). Download: WorkStation
    and Server
  • Native in Windows 2000 (aka «NT5»): Beta 2 has
    GQOS with RSVP, Differentiated Services, Traffic Control & Policy Enforcement.

Send Posted

Event ID = 18

Level = 5 (Verbose)

In order to diagnose user buffer corruption (for example, when an application re-uses the same buffer in another send or receive call while it’s still in use), the data buffer is logged when posted to Winsock and upon completion by the underlying transport. The following Winsock events are traced for socket send and receive buffer post operations:

  • An application posts a send.
  • A send operation completes to Winsock.

The following parameters are logged for socket send operations:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
FastPath A Boolean value that indicates if fast path I/O was used.
BufferCount The buffer count.
Buffer The virtual address of the buffer. For chained buffers, this parameter is the virtual address of the first buffer in the chain.
BufferLength The length of the buffer. For chained buffers, this parameter is the total number of bytes in all of the buffers in the chain.

When FastPath is true, the usermode address of the first buffer in the array of buffers is logged in the Buffer parameter. When FastPath is false, the Winsock kernel buffer address is logged in the Buffer parameter.

Причины uTorrent WSAStartup () не удались, или установлена ​​некорректная версия WinSock.?

Если вы получили эту ошибку на своем ПК, это означает, что произошла сбой в работе вашей системы. Общие причины включают неправильную или неудачную установку или удаление программного обеспечения, которое может привести к недействительным записям в вашем реестре Windows, последствиям атаки вирусов или вредоносных программ, неправильному отключению системы из-за сбоя питания или другого фактора, кто-то с небольшими техническими знаниями, случайно удалив необходимый системный файл или запись в реестре, а также ряд других причин. Непосредственная причина «uTorrent WSAStartup () не удалась, или у вас установлена ​​некорректная версия WinSock». ошибка — это неправильное выполнение одной из обычных операций с помощью системного или прикладного компонента.

SendMsg Completed

Event ID = 25

Level = 5 (Verbose)

In order to diagnose user buffer corruption (for example, when an application re-uses the same buffer in another send or receive call while it’s still in use), the data buffer is logged when posted to Winsock and upon completion by the underlying transport. The following Winsock events are traced when a WSASendMsg buffer post operation completes on a socket:

An application completes a WSASendMsg operation.

The following parameters are logged for the WSASendMsg completion:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
BufferCount The buffer count.
Buffer The virtual address of the buffer. For chained buffers, this parameter is the virtual address of the first buffer in the chain.
BufferLength The length of the buffer of bytes sent. For chained buffers, this parameter is the total bytes sent from all buffers in the chain.
Address The remote IP address of the socket.
Port The remote IP port number of the socket.

SendTo Posted

Event ID = 21 (IPv4), Event ID = 22 (IPv6)

Level = 5 (Verbose)

In order to diagnose user buffer corruption (for example, when an application re-uses the same buffer in another send or receive call while it’s still in use), the data buffer is logged when posted to Winsock and upon completion by the underlying transport. The following Winsock events are traced for a sendto buffer post operation on a socket:

An application posts a send from.

The following parameters are logged for the sendto operation:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
FastPath A Boolean value that indicates if fast path I/O was used.
BufferCount The buffer count.
Buffer The virtual address of the buffer. For chained buffers, this parameter is the virtual address of the first buffer in the chain.
BufferLength The length of the buffer. For chained buffers, this parameter is the total number of bytes in all of the buffers in the chain.
Address The remote IP address of the socket.
Port The remote IP port number of the socket.

When FastPath is true, the usermode address of the first buffer in the array of buffers is logged in the Buffer parameter. When FastPath is false, the Winsock kernel buffer address is logged in the Buffer parameter.

Socket Option Set

Event ID = 29

Level = 5 (Verbose)

Whenever an application changes certain socket option values and Ioctls, the new values will be logged. The options logged can be used to diagnose poor performance or strange behavior in applications. The following Winsock events are traced for certain socket options and Ioctls:

  • SO_SNDBUF changes.
  • SO_RCVBUF changes.
  • FIONBIO
  • SIO_ENABLE_CIRCULAR_QUEUEING
  • SIO_UDP_CONNRESET
  • SO_OOBINLINE

The following parameters are logged for setsockopt and WSAIoctl function calls that change any of the above values:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
Option The socket option or Ioctl that is changed.
Value The new value for the socket option or Ioctl.

Socket Connect

Event ID = 4 (IPv4), Event ID = 5 (IPv6)

Level = 4 (Information)

The following Winsock events are traced for a connect operation request (a call to the connect, ConnectEx, WSAConnect, WSAConnectByList, or WSAConnectByName function):

Connecting a socket to a destination for either a connection-oriented or a connectionless socket.

The following parameters are logged for a connect event:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
Address The remote IP address.
Port The remote IP port number.

Parameters

A descriptor that identifies a connected socket.

A pointer to an array of
WSABUF structures. Each
WSABUF structure contains a pointer to a buffer and the length, in bytes, of the buffer. For a Winsock application, once the
WSASend function is called, the system owns these buffers and the application may not access them. This array must remain valid for the duration of the send operation.

The number of
WSABUF structures in the lpBuffers array.

A pointer to the number, in bytes, sent by this call if the I/O operation completes immediately.

Use NULL for this parameter if the lpOverlapped parameter is not NULL to avoid potentially erroneous results. This parameter can be NULL only if the lpOverlapped parameter is not NULL.

The flags used to modify the behavior of the
WSASend function call. For more information, see Using dwFlags in the Remarks section.

A pointer to a
WSAOVERLAPPED structure. This parameter is ignored for nonoverlapped sockets.

A pointer to the completion routine called when the send operation has been completed. This parameter is ignored for nonoverlapped sockets.

Receive Posted

Event ID = 19

Level = 5 (Verbose)

In order to diagnose user buffer corruption (for example, when an application re-uses the same buffer in another send or receive call while it’s still in use), the data buffer is logged when posted to Winsock and upon completion by the underlying transport. The following Winsock events are traced for socket receive buffer post operations:

  • An application posts a receive.
  • A receive operation completes to Winsock.

The following parameters are logged for socket receive operations:

Parameter Description
Process The kernel EPROCESS structure address for the process.
Endpoint The Winsock kernel socket address used as a unique identifier for a socket.
FastPath A Boolean value that indicates if fast path I/O was used.
BufferCount The buffer count.
Buffer The virtual address of the buffer. For chained buffers, this parameter is the virtual address of the first buffer in the chain.
BufferLength The length of the buffer. For chained buffers, this parameter is the total number of bytes in all of the buffers in the chain.

When FastPath is true, the usermode address of the first buffer in the array of buffers is logged in the Buffer parameter. When FastPath is false, the Winsock kernel buffer address is logged in the Buffer parameter.

Remarks

The WSAPOLLFD structure is defined on Windows Vista and later.

The WSAPOLLFD structure is used by the WSAPoll function to determine the status of one or more sockets. The set of sockets for which status is requested is specified in fdarray parameter, which is an array of WSAPOLLFD structures. An application sets the appropriate flags in the events member of the WSAPOLLFD structure to specify the type of status requested for each corresponding socket. The WSAPoll function returns the status of a socket in the revents member of the WSAPOLLFD structure.

If the fd member of the WSAPOLLFD structure is set to a negative value, the structure is ignored by the WSAPoll function call, and the revents member is cleared upon return. This is useful to applications that maintain a fixed allocation for the fdarray parameter of WSAPoll; such applications need not waste resources compacting elements of the array for unused entries or reallocating memory. It is unnecessary to clear the revents member prior to calling the WSAPoll function.

Return value

Upon successful completion, the
WSAIoctl returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling
WSAGetLastError.

Error code Meaning
WSA_IO_PENDING
An overlapped operation was successfully initiated and completion will be indicated at a later time.
WSAENETDOWN
The network subsystem has failed.
WSAEFAULT
The lpvInBuffer, lpvOutBuffer, lpcbBytesReturned, lpOverlapped, or lpCompletionRoutine parameter is not totally contained in a valid part of the user address space, or the cbInBuffer or cbOutBuffer parameter is too small.
WSAEINVAL
The dwIoControlCode parameter is not a valid command, or a specified input parameter is not acceptable, or the command is not applicable to the type of socket specified.
WSAEINPROGRESS
The function is invoked when a callback is in progress.
WSAENOTSOCK
The descriptor s is not a socket.
WSAEOPNOTSUPP
The specified IOCTL command cannot be realized. (For example, the
FLOWSPEC structures specified in SIO_SET_QOS or SIO_SET_GROUP_QOS cannot be satisfied.)
WSAEWOULDBLOCK
The socket is marked as non-blocking and the requested operation would block.
WSAENOPROTOOPT
The socket option is not supported on the specified protocol. For example, an attempt to use the SIO_GET_BROADCAST_ADDRESS IOCTL was made on an IPv6 socket or an attempt to use the TCP SIO_KEEPALIVE_VALS IOCTL was made on a datagram socket.

Using logman and tracert

Winsock network event tracing is disabled by default on Windows Vista and later.

The following command starts Winsock network event tracing on a computer, sets the name of event trace session to mywinsocksession, and sends output to a binary log file called winsocklogfile.etl:

logman start -ets mywinsocksession -o winsocklogfile.etl -p Microsoft-Windows-Winsock-AFD

Log files are created in the current directory with filenames of the form winsocklogfile_000001.etl

The following command stops the above Winsock tracing on a computer for the session named mywinsocksession:

logman stop -ets mywinsocksession

A binary log file will be written to the location specified by the –o parameter. To translate the binary file into a readable text file, tracerpt.exe is used:

tracerpt.exe <name of the .etl file> –o winsocktracelog.txt

If an output file containing xml rather than plain text is preferred, the following command is used:

tracerpt.exe <name of the .etl file> –o winsocktracelog.xml –of xml

Winsock catalog change tracing is enabled by default on Windows Vista and later.

Note

Layered Service Providers are deprecated. Starting with Windows 8 and Windows Server 2012, use Windows Filtering Platform.

The following command starts Winsock Catalog Change tracing for layered service providers (LSPs) on a computer, sets the name of event trace session to mywinsockcatalogsession, and sends output to a binary log file called winsockcataloglogfile.etl:

logman start -ets mywinsockcatalogsession -o winsockcataloglogfile.etl -p Microsoft-Windows-Winsock-WS2HELP

Log files are created in the current directory with filenames of the form winsockcataloglogfile_000001.etl

The following command stops the above Winsock tracing on a computer for the session named mysession:

logman stop -ets mywinsockcatalogsession

A binary log file will be written to the location specified by the –o parameter. To translate the binary file into a readable text file, tracerpt.exe is used:

tracerpt.exe <name of the .etl file> –o winsockcatalogtracelog.txt

If an output file containing xml rather than plain text is preferred, the following command is used:

tracerpt.exe <name of the .etl file> –o winsockcatalogtracelog.xml –of xml

Return value

If no error occurs and the send operation has completed immediately,
WSASendTo returns zero. In this case, the completion routine will have already been scheduled to be called once the calling thread is in the alertable state. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling
WSAGetLastError. The error code WSA_IO_PENDING indicates that the overlapped operation has been successfully initiated and that completion will be indicated at a later time. Any other error code indicates that the overlapped operation was not successfully initiated and no completion indication will occur.

Error code Meaning
WSAEACCES
The requested address is a broadcast address, but the appropriate flag was not set.
WSAEADDRNOTAVAIL
The remote address is not a valid address (such as ADDR_ANY).
WSAEAFNOSUPPORT
Addresses in the specified family cannot be used with this socket.
WSAECONNRESET
For a UDP datagram socket, this error would indicate that a previous send operation resulted in an ICMP «Port Unreachable» message.
WSAEDESTADDRREQ
A destination address is required.
WSAEFAULT
The lpBuffers, lpTo, lpOverlapped, lpNumberOfBytesSent, or lpCompletionRoutine parameters are not part of the user address space, or the lpTo parameter is too small.
WSAEHOSTUNREACH
A socket operation was attempted to an unreachable host.
WSAEINPROGRESS
A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
WSAEINTR
A blocking Windows Socket 1.1 call was canceled through
WSACancelBlockingCall.
WSAEINVAL
The socket has not been bound with
bind, or the socket is not created with the overlapped flag.
WSAEMSGSIZE
The socket is message oriented, and the message is larger than the maximum supported by the underlying transport.
WSAENETDOWN
The network subsystem has failed.
WSAENETRESET
For a datagram socket, this error indicates that the time to live has expired.
WSAENETUNREACH
The network cannot be reached from this host at this time.
WSAENOBUFS
The Windows Sockets provider reports a buffer deadlock.
WSAENOTCONN
The socket is not connected (connection-oriented sockets only).
WSAENOTSOCK
The descriptor is not a socket.
WSAESHUTDOWN
The socket has been shut down; it is not possible to
WSASendTo on a socket after
shutdown has been invoked with how set to SD_SEND or SD_BOTH.
WSAEWOULDBLOCK
Windows NT:  

Overlapped sockets: there are too many outstanding overlapped I/O requests. Nonoverlapped sockets: The socket is marked as nonblocking and the send operation cannot be completed immediately.

WSANOTINITIALISED
A successful
WSAStartup call must occur before using this function.
WSA_IO_PENDING
An overlapped operation was successfully initiated and completion will be indicated at a later time.
WSA_OPERATION_ABORTED
The overlapped operation has been canceled due to the closure of the socket, or the execution of the SIO_FLUSH command in
WSAIoctl.

Introduction

Winsock tracing is a troubleshooting feature that can be enabled in retail binaries to trace certain Windows socket events with minimal overhead. The goal of adding retail tracing to Windows Sockets is to allow for better diagnostic capabilities for developers and product support. Winsock network event tracing supports tracing socket operations for IPv4 and IPv6 applications. Winsock catalog change tracing supports tracing changes made to the Winsock catalog by layered service providers (LSPs). Winsock tracing is supported on Windows Vista and later.

Note

Layered Service Providers are deprecated. Starting with Windows 8 and Windows Server 2012, use Windows Filtering Platform.

When an unexpected error occurs on a socket, the main clue to diagnose the problem is the error code returned. Very often, the returned error code does not explain why the error happened, especially when the error is initiated by the underlying network transport. Winsock tracing provides a more verbose tracing level which can log additional information to catch buffer corruption and poorly written applications.

Winsock tracing uses Event Tracing for Windows (ETW), a general-purpose, high-speed tracing facility provided by the operating system. Using a buffering and logging mechanism implemented in the kernel, ETW provides a tracing mechanism for events raised by both user-mode applications and kernel-mode device drivers. Additionally, ETW gives you the ability to enable and disable logging dynamically, making it easy to perform detailed tracing in production environments without requiring reboots or application restarts. The logging mechanism uses buffers that are written to disk by an asynchronous writer thread. This allows large-scale server applications to write events with minimum disturbance. ETW was first introduced on Windows 2000. Support for Winsock tracing using ETW was added on Windows Vista and later. For general information on ETW, see Improve Debugging And Performance Tuning With ETW.

Winsock tracing can only be enabled at the operating system level for all processes and threads running on a computer. Winsock tracing currently cannot be enabled for just a single process or thread. When Winsock network event tracing is enabled, all socket applications (both IPv4 and IPv6) on a computer are traced.

The following topics describe Winsock tracing in more detail:

  • Winsock Tracing Levels
  • Control of Winsock Tracing
  • Winsock Network Event Tracing Details
  • Winsock Catalog Change Tracing Details

Remarks

The
WSAGetLastError function returns the last error that occurred for the calling thread. When a particular Windows Sockets function indicates an error has occurred, this function should be called immediately to retrieve the extended error code for the failing function call. This extended error code can be different from the error code obtained from
getsockopt when called with an optname parameter of SO_ERROR, which is socket-specific since
WSAGetLastError is for all thread-specific sockets.

If a function call’s return value indicates that error or other relevant data was returned in the error code, WSAGetLastError should be called immediately. This is necessary because some functions may reset the last extended error code to 0 if they succeed, overwriting the extended error code returned by a previously failed function. To specifically reset the extended error code, use the
WSASetLastError function call with the iError parameter set to zero. A
getsockopt function when called with an optname parameter of SO_ERROR also resets the extended error code to zero.

The
WSAGetLastError function should not be used to check for an extended error value on receipt of an asynchronous message. In this case, the extended error value is passed in the lParam parameter of the message, and this can differ from the value returned by
WSAGetLastError.

Note  An application can call the WSAGetLastError function to determine the extended error code for other Windows sockets functions as is normally done in Windows Sockets even if
the WSAStartup function fails or the WSAStartup function was not called to properly initialize Windows Sockets before calling a Windows Sockets function. The WSAGetLastError function is one of the only functions in the Winsock 2.2 DLL that can be called in the case of a WSAStartup failure.
 

The Windows Sockets extended error codes returned by this function and the text description of the error are listed under Windows Sockets Error Codes. These error codes and a short text description associated with an error code are defined in the Winerror.h header file. The FormatMessage function can be used to obtain the message string for the returned error.

For information on how to handle error codes when porting socket applications to Winsock, see Error Codes — errno, h_errno and WSAGetLastError.

Windows Phone 8: This function is supported for Windows Phone Store apps on Windows Phone 8 and later.

Windows 8.1 and Windows Server 2012 R2: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.

Return value

If successful, the
WSAStartup function returns zero. Otherwise, it returns one of the error codes listed below.

The WSAStartup function directly returns the extended error code in the return value for this function. A call to the WSAGetLastError function is not needed and should not be used.

Error code Meaning
WSASYSNOTREADY
The underlying network subsystem is not ready for network communication.
WSAVERNOTSUPPORTED
The version of Windows Sockets support requested is not provided by this particular Windows Sockets implementation.
WSAEINPROGRESS
A blocking Windows Sockets 1.1 operation is in progress.
WSAEPROCLIM
A limit on the number of tasks supported by the Windows Sockets implementation has been reached.
WSAEFAULT
The lpWSAData parameter is not a valid pointer.
Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector