本文整理汇总了C++中PDSOCKET::DropDSocketReference方法的典型用法代码示例。如果您正苦于以下问题:C++ PDSOCKET::DropDSocketReference方法的具体用法?C++ PDSOCKET::DropDSocketReference怎么用?C++ PDSOCKET::DropDSocketReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDSOCKET
的用法示例。
在下文中一共展示了PDSOCKET::DropDSocketReference方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetLastError
int WSAAPI
WSAEventSelect(
IN SOCKET s,
IN WSAEVENT hEventObject,
IN long lNetworkEvents
)
/*++
Routine Description:
Specify an event object to be associated with the supplied set of
FD_XXX network events.
Arguments:
s - A descriptor identifying the socket.
hEventObject - A handle identifying the event object to be
associated with the supplied set of FD_XXX network
events.
lNetworkEvents - A bitmask which specifies the combination of
FD_XXX network events in which the application
has interest.
Returns:
Zero on success else SOCKET_Error. The error code is stored with
SetLastError().
--*/
{
INT ReturnValue;
INT ErrorCode;
PDPROVIDER Provider;
PDSOCKET Socket;
ErrorCode = TURBO_PROLOG();
if (ErrorCode == ERROR_SUCCESS) {
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL){
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPEventSelect(
s,
hEventObject,
lNetworkEvents,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return SOCKET_ERROR;
} //WSAEventSelect
示例2: SetLastError
int WSAAPI
bind(
IN SOCKET s,
IN const struct sockaddr FAR *name,
IN int namelen
)
/*++
Routine Description:
Associate a local address with a socket.
Arguments:
s - A descriptor identifying an unbound socket.
name - The address to assign to the socket.
namelen - The length of the name.
Returns:
Zero on success else SOCKET_ERROR. The error code is stored with
SetLastError().
--*/
{
INT ReturnValue;
PDPROVIDER Provider;
INT ErrorCode;
PDSOCKET Socket;
ErrorCode = TURBO_PROLOG();
if (ErrorCode==ERROR_SUCCESS)
{
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL) {
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPBind(s,
name,
namelen,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return SOCKET_ERROR;
}
示例3: address
int WSAAPI
getsockname(
IN SOCKET s,
OUT struct sockaddr FAR *name,
OUT int FAR * namelen
)
/*++
Routine Description:
Get the local name for a socket.
Arguments:
s - A descriptor identifying a bound socket.
name - Receives the address (name) of the socket.
namelen - The size of the name buffer.
Returns:
Zero on success else SOCKET_ERROR. The error code is stored with
SetLastError().
--*/
{
INT ReturnValue;
INT ErrorCode;
PDPROVIDER Provider;
PDSOCKET Socket;
ErrorCode = TURBO_PROLOG();
if (ErrorCode == ERROR_SUCCESS) {
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL) {
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPGetSockName(s,
name,
namelen,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return SOCKET_ERROR;
}
示例4: SetErrorCode
int WSAAPI
WSARecvDisconnect(
IN SOCKET s,
OUT LPWSABUF lpInboundDisconnectData
)
/*++
Routine Description:
Terminate reception on a socket, and retrieve the disconnect data if the
socket is connection-oriented.
Arguments:
s - A descriptor identifying a socket.
lpInboundDisconnectData - A pointer to the incoming disconnect data.
Returns:
Zero on success else SOCKET_ERROR. The error code is stored with
SetErrorCode().
--*/
{
PDPROCESS Process;
PDTHREAD Thread;
INT ErrorCode;
PDSOCKET Socket;
ErrorCode = PROLOG (&Process,&Thread);
if (ErrorCode==ERROR_SUCCESS) {
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL){
INT ReturnValue;
PDPROVIDER Provider;
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPRecvDisconnect(
s,
lpInboundDisconnectData,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ERROR_SUCCESS;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return(SOCKET_ERROR);
}
示例5: WSAHtonl
int WSAAPI
WSAHtonl (
IN SOCKET s,
IN u_long hostlong,
OUT u_long FAR * lpnetlong
)
/*++
Routine Description:
Convert a u_long from a specified host byte order to network byte
order.
Arguments:
s - A descriptor identifying a socket.
hostlong - A 32-bit number in host byte order.
lpnetlong - A pointer to a 32-bit number in network byte order.
Returns:
If no error occurs, WSAHtonl() returns 0. Otherwise, a value of
SOCKET_ERROR is returned.
--*/
{
PDSOCKET Socket;
INT ErrorCode;
PPROTO_CATALOG_ITEM CatalogEntry;
LPWSAPROTOCOL_INFOW ProtocolInfo;
ErrorCode = TURBO_PROLOG();
if (ErrorCode==ERROR_SUCCESS) {
if( lpnetlong == NULL ) {
SetLastError( WSAEFAULT );
return(SOCKET_ERROR);
}
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL){
CatalogEntry = Socket->GetCatalogItem();
ProtocolInfo = CatalogEntry->GetProtocolInfo();
__try {
if (LITTLEENDIAN == ProtocolInfo->iNetworkByteOrder) {
*lpnetlong = hostlong;
} //if
else {
*lpnetlong = SWAP_LONG( hostlong );
} //else
ErrorCode = ERROR_SUCCESS;
}
__except (WS2_EXCEPTION_FILTER()) {
ErrorCode = WSAEFAULT;
}
Socket->DropDSocketReference();
if (ErrorCode==ERROR_SUCCESS)
return ErrorCode;
} //if
else
示例6: select
int WSAAPI
select (
IN int nfds,
IN OUT fd_set FAR *readfds,
IN OUT fd_set FAR *writefds,
IN OUT fd_set FAR *exceptfds,
IN const struct timeval FAR *timeout
)
/*++
Routine Description:
Determine the status of one or more sockets, waiting if necessary.
Arguments:
nfds - This argument is ignored and included only for the sake of
compatibility.
readfds - An optional pointer to a set of sockets to be checked
for readability.
writefds - An optional pointer to a set of sockets to be checked
for writability.
exceptfds - An optional pointer to a set of sockets to be checked
for errors.
timeout - The maximum time for select() to wait, or NULL for
blocking operation.
Returns:
select() returns the total number of descriptors which are ready
and contained in the fd_set structures, 0 if the time limit
expired, or SOCKET_ERROR if an error occurred. If the return
value is SOCKET_ERROR, The error code is stored with
SetLastError().
--*/
{
INT ReturnValue;
INT ErrorCode;
PDPROVIDER Provider;
PDSOCKET Socket;
SOCKET SocketID;
BOOL FoundSocket=FALSE;
ErrorCode = TURBO_PROLOG();
if (ErrorCode == ERROR_SUCCESS) {
__try {
// Look for a socket in the three fd_sets handed in. The first
// socket found will be used to select the service provider to
// service this call
if (readfds && readfds->fd_count)
{
SocketID = readfds->fd_array[0];
FoundSocket = TRUE;
} //if
if (!FoundSocket && writefds && writefds->fd_count )
{
SocketID = writefds->fd_array[0];
FoundSocket = TRUE;
} //if
if (!FoundSocket && exceptfds && exceptfds->fd_count )
{
SocketID = exceptfds->fd_array[0];
FoundSocket = TRUE;
} //if
}
__except (WS2_EXCEPTION_FILTER()) {
ErrorCode = WSAEFAULT;
goto ReturnError;
}
if (FoundSocket) {
Socket = DSOCKET::GetCountedDSocketFromSocket(SocketID);
if(Socket != NULL){
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPSelect(
nfds,
readfds,
writefds,
exceptfds,
timeout,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue!=SOCKET_ERROR)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
} //if
else {
ErrorCode = WSAENOTSOCK;
}
} //if
//.........这里部分代码省略.........
示例7: WSAGetLastError
int WSAAPI
WSAAsyncSelect(
IN SOCKET s,
IN HWND hWnd,
IN u_int wMsg,
IN long lEvent
)
/*++
Routine Description:
Request event notification for a socket.
Arguments:
s - A descriptor identifying the socket for which event notification is
required.
hWnd - A handle identifying the window which should receive a message when
a network event occurs.
wMsg - The message to be received when a network event occurs.
lEvent - A bitmask which specifies a combination of network events in which
the application is interested.
Returns:
The return value is 0 if the application's declaration of interest in the
network event set was successful. Otherwise the value SOCKET_ERROR is
returned, and a specific error number may be retrieved by calling
WSAGetLastError().
--*/
{
INT ReturnValue;
INT ErrorCode;
PDPROVIDER Provider;
PDSOCKET Socket;
ErrorCode = TURBO_PROLOG();
if (ErrorCode == ERROR_SUCCESS) {
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL){
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPAsyncSelect(
s,
hWnd,
wMsg,
lEvent,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return SOCKET_ERROR;
} //WSAAsyncSelect
示例8: SetErrorCode
int WSAAPI
WSANtohs (
IN SOCKET s,
IN u_short netshort,
OUT u_short FAR * lphostshort
)
/*++
Routine Description:
Arguments:
Returns:
Zero on success else SOCKET_ERROR. The error code is stored with
SetErrorCode().
--*/
{
PDPROCESS Process;
PDTHREAD Thread;
PDSOCKET Socket;
INT ErrorCode;
INT ReturnCode;
PPROTO_CATALOG_ITEM CatalogEntry;
LPWSAPROTOCOL_INFOW ProtocolInfo;
ReturnCode = PROLOG(
&Process,
&Thread,
&ErrorCode);
if (ERROR_SUCCESS != ReturnCode) {
SetLastError(ErrorCode);
return(SOCKET_ERROR);
} //if
if( lphostshort == NULL ) {
SetLastError( WSAEFAULT );
return(SOCKET_ERROR);
}
ErrorCode = DSOCKET::GetCountedDSocketFromSocket(
s, // SocketHandle
& Socket); // DSocket
if(ERROR_SUCCESS == ErrorCode){
CatalogEntry = Socket->GetCatalogItem();
// This is kind of a special case. We are done with the DSOCKET
// object reference and we don't call through to the provider at
// all.
Socket->DropDSocketReference();
ProtocolInfo = CatalogEntry->GetProtocolInfo();
if (LITTLEENDIAN == ProtocolInfo->iNetworkByteOrder) {
*lphostshort = netshort;
} //if
else {
*lphostshort = SWAP_SHORT( netshort );
} //else
} //if
if (ErrorCode != ERROR_SUCCESS) {
SetLastError(ErrorCode);
ReturnCode = SOCKET_ERROR;
}
return(ReturnCode);
}
示例9: WSANtohs
int WSAAPI
WSANtohl (
IN SOCKET s,
IN u_long netlong,
OUT u_long FAR * lphostlong
)
/*++
Routine Description:
Convert a u_long from network byte order to host byte order.
Arguments:
s - A descriptor identifying a socket.
netlong - A 32-bit number in network byte order.
lphostlong - A pointer to a 32-bit number in host byte order.
Returns:
If no error occurs, WSANtohs() returns 0. Otherwise, a value of
SOCKET_ERROR is returned.
--*/
{
PDPROCESS Process;
PDTHREAD Thread;
PDSOCKET Socket;
INT ErrorCode;
INT ReturnCode;
PPROTO_CATALOG_ITEM CatalogEntry;
LPWSAPROTOCOL_INFOW ProtocolInfo;
ReturnCode = PROLOG(
&Process,
&Thread,
&ErrorCode);
if (ERROR_SUCCESS != ReturnCode) {
SetLastError(ErrorCode);
return(SOCKET_ERROR);
} //if
if( lphostlong == NULL ) {
SetLastError( WSAEFAULT );
return(SOCKET_ERROR);
}
ErrorCode = DSOCKET::GetCountedDSocketFromSocket(
s, // SocketHandle
& Socket); // DSocket
if(ERROR_SUCCESS == ErrorCode){
CatalogEntry = Socket->GetCatalogItem();
// This is kind of a special case. We are done with the DSOCKET
// object reference and we don't call through to the provider at
// all.
Socket->DropDSocketReference();
ProtocolInfo = CatalogEntry->GetProtocolInfo();
if (LITTLEENDIAN == ProtocolInfo->iNetworkByteOrder) {
*lphostlong = netlong;
} //if
else {
*lphostlong = SWAP_LONG( netlong );
} //else
} //if
if (ErrorCode != ERROR_SUCCESS) {
SetLastError(ErrorCode);
ReturnCode = SOCKET_ERROR;
}
return(ReturnCode);
}
示例10: structure
int WSAAPI
WSARecvFrom(
IN SOCKET s,
OUT LPWSABUF lpBuffers,
IN DWORD dwBufferCount,
OUT LPDWORD lpNumberOfBytesRecvd,
IN OUT LPDWORD lpFlags,
OUT struct sockaddr FAR * lpFrom,
IN OUT LPINT lpFromlen,
IN LPWSAOVERLAPPED lpOverlapped,
IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
)
/*++
Routine Description:
Receive a datagram and store the source address.
Arguments:
s - A descriptor identifying a socket
lpBuffers - A pointer to an array of WSABUF structures. Each
WSABUF structure contains a pointer to a buffer and
the length of the buffer.
dwBufferCount - The number of WSABUF structures in the lpBuffers
array.
lpNumberOfBytesRecvd - A pointer to the number of bytes received by this
call if the receive operation completes immediately.
lpFlags - A pointer to flags.
lpFrom - An optional pointer to a buffer which will hold the
source address upon the completion of the overlapped
operation.
lpFromlen - A pointer to the size of the from buffer, required
only if lpFrom is specified.
lpOverlapped - A pointer to a WSAOVERLAPPED structure (ignored for
non- overlapped sockets).
lpCompletionRoutine - A pointer to the completion routine called when the
receive operation has been completed (ignored for
non-overlapped sockets).
Returns:
Zero on success else SOCKET_ERROR. The error code is stored with
SetErrorCode().
--*/
{
INT ErrorCode;
PDSOCKET Socket;
LPWSATHREADID ThreadId;
ErrorCode = TURBO_PROLOG_OVLP(&ThreadId);
if (ErrorCode==ERROR_SUCCESS)
{
Socket = DSOCKET::GetCountedDSocketFromSocket(s);
if(Socket != NULL){
INT ReturnValue;
PDPROVIDER Provider;
Provider = Socket->GetDProvider();
ReturnValue = Provider->WSPRecvFrom(s,
lpBuffers,
dwBufferCount,
lpNumberOfBytesRecvd,
lpFlags,
lpFrom,
lpFromlen,
lpOverlapped,
lpCompletionRoutine,
ThreadId,
&ErrorCode);
Socket->DropDSocketReference();
if (ReturnValue==ERROR_SUCCESS)
return ReturnValue;
assert (ErrorCode!=NO_ERROR);
if (ErrorCode==NO_ERROR)
ErrorCode = WSASYSCALLFAILURE;
}
else {
ErrorCode = WSAENOTSOCK;
}
}
SetLastError(ErrorCode);
return SOCKET_ERROR;
}