因为是流数据所以用了 MSG_OOB to DentistryDoctor(牙医的目标是没有蛀牙) ( ) 如果我填入一个已知得字符串如char *test=“this is a test”,这样发送send(soc,test,15,MSG_OOB);则为ok,所以我觉得可能是我的参数没有给对。
关键你要知道为什么返回10053 #define WSAECONNABORTED (WSABASEERR+53) //10053 The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable. 您的主机中的软件放弃了一个已建立的连接。
这是一个从directsound取得数据然后发送到网络客户端得函数,现在就是发送得数据有问题,我猜测可能是send得参数有问题BOOL RecordCapturedData(SOCKET soc) { HRESULT hr; VOID* pbCaptureData = NULL; DWORD dwCaptureLength; VOID* pbCaptureData2 = NULL; DWORD dwCaptureLength2; DWORD dwReadPos; LONG lLockSize; UINT dwDataWrote; memset(CaptureData,0,sizeof(CaptureData)); TCHAR szError[100]; if( NULL == g_pDSBCapture ) return S_FALSE; if( FAILED( hr = g_pDSBCapture->GetCurrentPosition( &dwCapturePos, &dwReadPos ) ) ) return DXTRACE_ERR_MSGBOX( TEXT("GetCurrentPosition"), hr ); lLockSize = dwReadPos - g_dwNextCaptureOffset; if( lLockSize < 0 ) lLockSize += g_dwCaptureBufferSize; // Block align lock size so that we are always write on a boundary lLockSize -= (lLockSize % g_dwNotifySize); if( lLockSize == 0 ) return S_FALSE; // Lock the capture buffer down g_pDSBCapture->Lock(g_dwNextCaptureOffset,lLockSize,&pbCaptureData,&dwCaptureLength, &pbCaptureData2, &dwCaptureLength2, 0L); int sendlength=send(soc,(char*)pbCaptureData,dwCaptureLength,MSG_OOB); if(sendlength== SOCKET_ERROR) { wsprintf (szError, TEXT("Sending data to the client failed. Error: %d"),WSAGetLastError ()); return 1; MessageBox (NULL, szError, TEXT("Error"), MB_OK); } // Move the capture offset along
如果我填入一个已知得字符串如char *test=“this is a test”,这样发送send(soc,test,15,MSG_OOB);则为ok,所以我觉得可能是我的参数没有给对。
#define WSAECONNABORTED (WSABASEERR+53) //10053
The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.
您的主机中的软件放弃了一个已建立的连接。
{
HRESULT hr;
VOID* pbCaptureData = NULL;
DWORD dwCaptureLength;
VOID* pbCaptureData2 = NULL;
DWORD dwCaptureLength2;
DWORD dwReadPos; LONG lLockSize;
UINT dwDataWrote;
memset(CaptureData,0,sizeof(CaptureData));
TCHAR szError[100];
if( NULL == g_pDSBCapture )
return S_FALSE; if( FAILED( hr = g_pDSBCapture->GetCurrentPosition( &dwCapturePos, &dwReadPos ) ) )
return DXTRACE_ERR_MSGBOX( TEXT("GetCurrentPosition"), hr ); lLockSize = dwReadPos - g_dwNextCaptureOffset;
if( lLockSize < 0 )
lLockSize += g_dwCaptureBufferSize; // Block align lock size so that we are always write on a boundary
lLockSize -= (lLockSize % g_dwNotifySize); if( lLockSize == 0 )
return S_FALSE; // Lock the capture buffer down
g_pDSBCapture->Lock(g_dwNextCaptureOffset,lLockSize,&pbCaptureData,&dwCaptureLength, &pbCaptureData2, &dwCaptureLength2, 0L);
int sendlength=send(soc,(char*)pbCaptureData,dwCaptureLength,MSG_OOB);
if(sendlength== SOCKET_ERROR)
{
wsprintf (szError, TEXT("Sending data to the client failed. Error: %d"),WSAGetLastError ());
return 1;
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
} // Move the capture offset along
g_dwNextCaptureOffset += dwCaptureLength;
g_dwNextCaptureOffset %= g_dwCaptureBufferSize; // Circular buffer
if( pbCaptureData2 != NULL )
{
//////////////////
sendlength=send(soc,(char*)pbCaptureData2,dwDataWrote,MSG_OOB);
if(sendlength==SOCKET_ERROR)
{
wsprintf (szError, TEXT("Sending data to the client failed. Error: %d"),WSAGetLastError ());
MessageBox (NULL, szError, TEXT("Error"), MB_OK);
} // Move the capture offset along
g_dwNextCaptureOffset += dwCaptureLength2;
g_dwNextCaptureOffset %= g_dwCaptureBufferSize; // Circular buffer
}
// Unlock the capture buffer
g_pDSBCapture->Unlock( pbCaptureData,dwCaptureLength, pbCaptureData2, dwCaptureLength2 );
return 0;
}
char *test=“this is a test”;
send(soc,test,15,MSG_OOB);
则为ok,所以我觉得可能是我的参数没有给对。
这样的话转为char *类型发送时,遇到\0就会认为字符串结束?