Skip to main content
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.

Syntax


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

Parameters

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
WSAEAFNOSUPPORT

The specified address family is not supported.

WSAEFAULT

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.

WSAEINVAL

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.

WSAEMSGSIZE

A buffer passed was too small.

WSAENOTSOCK

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

 

Remarks

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.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Ws2tcpip.h

Library

Fwpuclnt.lib

DLL

Fwpuclnt.dll

See also

Using Secure Socket Extensions
Windows Filtering Platform
Windows Filtering Platform API Functions
Winsock Secure Socket Extensions
WSAImpersonateSocketPeer
WSAQuerySocketSecurity
WSARevertImpersonation
WSASetSocketPeerTargetName
WSASetSocketSecurity