Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

WSADeleteSocketPeerTargetName function

The WSADeleteSocketPeerTargetName function removes the association between a peer target name and an IP address for a socket. After a successful return, there will be no future association between the IP address and the target name.


int WSAAPI WSADeleteSocketPeerTargetName(
  _In_           SOCKET                             Socket,
  _In_     const struct sockaddr                    *PeerAddr,
  _In_           ULONG                              PeerAddrLen,
  _In_opt_       LPWSAOVERLAPPED                    Overlapped,


Socket [in]

A descriptor identifying a socket on which the peer target name is being deleted.

PeerAddr [in]

The IP address of the peer for which the target name is being deleted.

PeerAddrLen [in]

The size, in bytes, of the PeerAddr parameter.

Overlapped [in, optional]

A pointer to a WSAOVERLAPPED structure. This parameter is ignored for non-overlapped sockets.

CompletionRoutine [in, optional]

A pointer to the completion routine called when the operation has been completed. This parameter is ignored for non-overlapped sockets.

Return value

If the function succeeds, the return value is 0. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Some possible error codes are listed below.

Error codeMeaning

The specified address family is not supported.


The system detected an invalid address pointer in attempting to use a pointer argument of a call. This error is returned if the PeerAddr parameter was a NULL pointer.


An invalid parameter was passed. This error is returned if the socket passed in the Socket parameter was not created with an address family of the AF_INET or AF_INET6 and a socket type of SOCK_DGRAM or SOCK_STREAM.


A buffer passed was too small.


The descriptor passed in the Socket parameter is not a valid socket.



The WSADeleteSocketPeerTargetName function provides a method to remove the association between a peer target name and an IP address for a socket. This function is used to delete a peer target name that was previously set with the WSASetSocketPeerTargetName function. After the WSADeleteSocketPeerTargetName function returns, no future authentication to the IP address will use the previously specified target name. This function is primarily designed to be used by connectionless clients (for example, a socket created with the type set to SOCK_DGRAM or the protocol set to IPPROTO_UDP) after they have terminated the connection with the IP address associated with the peer target name. For connection oriented clients (for example, a socket created with the type set to SOCK_STREAM or protocol set to IPPROTO_TCP), this function should not be called.

The WSADeleteSocketPeerTargetName function simplifies having to call the WSAIoctl function with a dwIoControlCode parameter set to SIO_DELETE_PEER_TARGET_NAME.

An error will be returned if the following conditions are not met.

  • The address family of the Socket parameter must be either AF_INET or AF_INET6.
  • The socket type must be either SOCK_STREAM or SOCK_DGRAM.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]







See also

Using Secure Socket Extensions
Windows Filtering Platform
Windows Filtering Platform API Functions
Winsock Secure Socket Extensions



Community Additions

© 2015 Microsoft