ServiceAddPort (Windows CE 5.0)

Send Feedback

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

BOOL ServiceAddPort(HANDLEhService,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] Optional. String that contains the registry key associated with given service to pSockAddr, cbSockAddr, and iProtocol. Specifying szRegWritePath will ensure that the address specified in the function will automatically be listened on whenever the server initializes. The service must have been started with ActivateService, not RegisterService, for this to function.

Return Values

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, Services.exe will call accept on the socket and pass it to the xxx_IOControl (Services.exe) exported from the service, setting the function's dwCode parameter to IOCTL_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 or ServiceIoControl is called specifying the parameter IOCTL_SERVICE_STOP.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Service.h.
Link Library: Coredll.lib.

See Also

xxx_IOControl (Services.exe) | RegisterService | DeregisterService | DeviceIoControl | ServiceIoControl | Services.exe

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.