Share via


ServiceAddPort (Compact 2013)

3/26/2014

This function causes Services.exe to listen on the specified socket address and map network requests on the socket to the specified service instance.

Syntax

BOOL ServiceAddPort(
  HANDLE hService,
  SOCKADDR *pSockAddr,
  INT cbSockAddr,
  INT iProtocol,
  WCHAR szRegWritePath
);

Parameters

  • hService
    [in] Handle to the service instance that the socket is to be associated with.
  • pSockAddr
    [in] Pointer to the network address to listen on.
  • cbSockAddr
    [in] Length of pSockAddr.
  • iProtocol
    [in] Protocol of the socket.
  • szRegWritePath
    [in] This parameter is ignored and must be set to NULL.

Return Value

A nonzero value indicates success. A value of zero indicates failure. To get extended error information, call GetLastError.

Remarks

On calling ServiceAddPort, the values for pSockAddr, cbSockAddr, and iProtocol will be used to create a socket and bind and listen on the specified address.

When an incoming connection request takes place, Servicesd.exe will call accept on the socket and pass it to the xxx_IOControl (Servicesd.exe) exported from the service, setting the function's dwCode parameter toIOCTL_SERVICE_CONNECTION and passing the socket in the parameter pBufIn.

Super service sockets associated with a given service can be stopped with a call to ServiceUnbindPorts. They will also be stopped when the service is stopped during a call to DeregisterService and when DeviceIoControl is called specifying the parameter IOCTL_SERVICE_STOP.

Requirements

Header

service.h

Library

coredll.lib

See Also

Reference

Servicesd.exe Functions
xxx_IOControl (Servicesd.exe)
DeregisterService

Other Resources

DeviceIoControl
Servicesd.exe