本文整理汇总了C++中Recv函数的典型用法代码示例。如果您正苦于以下问题:C++ Recv函数的具体用法?C++ Recv怎么用?C++ Recv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Recv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GL_RecvLBS
static void
GL_RecvLBS(
NETFILE *fp,
LargeByteString *lbs)
{
size_t size;
ENTER_FUNC;
size = GL_RecvLength(fp);
LBS_ReserveSize(lbs,size,FALSE);
if ( size > 0 ) {
Recv(fp,LBS_Body(lbs),size);
if ( !CheckNetFile(fp) ) {
GL_Error();
}
} else {
dbgmsg("Recv LBS 0 size.");
}
LEAVE_FUNC;
}
示例2: accept
/** Thread that receives image from client.
* @param data struct dataTransfer casted variable.
* @return NULL
*/
void *asyncDataRecvImage_thread(void *data)
{
struct dataSend* _data = (struct dataSend*)data;
// Provide a server for the data transfer
int fd = accept(_data->fd, (struct sockaddr*)NULL, NULL);
if(fd < 0){
// we can't work, disconnect the client
printf("ERROR: Can't listen on binded port.\n"); fflush(stdout);
shutdown(_data->fd, 2);
return CL_SUCCESS;
}
// We may wait manually for the events generated by ocland,
// and then we can wait for the OpenCL generated ones.
if(_data->num_events_in_wait_list){
oclandWaitForEvents(_data->num_events_in_wait_list, _data->event_wait_list);
}
// Receive the data
Recv(&fd, _data->ptr, _data->cb, MSG_WAITALL);
// Writre it into the buffer
clEnqueueWriteImage(_data->command_queue,_data->mem,CL_FALSE,
_data->buffer_origin,_data->region,
_data->buffer_row_pitch,_data->buffer_slice_pitch,
_data->ptr,0,NULL,&(_data->event->event));
// Wait until the data is copied before start cleaning up
clWaitForEvents(1,&(_data->event->event));
// Clean up
free(_data->ptr); _data->ptr = NULL;
if(_data->event){
_data->event->status = CL_COMPLETE;
}
if(_data->want_event != CL_TRUE){
free(_data->event); _data->event = NULL;
}
if(_data->event_wait_list) free(_data->event_wait_list); _data->event_wait_list=NULL;
// shutdown(fd, 2);
// shutdown(_data->fd, 2); // Destroy the server to free the port
close(fd);
close(_data->fd);
free(_data); _data=NULL;
pthread_exit(NULL);
return NULL;
}
示例3: USB_RecvControl
// Does not timeout or cross fifo boundaries
int USB_RecvControl(void* d, int len)
{
auto length = len;
while(length)
{
// Dont receive more than the USB Control EP has to offer
// Use fixed 64 because control EP always have 64 bytes even on 16u2.
auto recvLength = length;
if(recvLength > 64){
recvLength = 64;
}
// Write data to fit to the end (not the beginning) of the array
WaitOUT();
Recv((u8*)d + len - length, recvLength);
ClearOUT();
length -= recvLength;
}
return len;
}
示例4: recv_until_flag
int recv_until_flag(int sockfd, const char *flg, int len_flg, char **ut_buf, u32 *pack_len)
{
const char *pFlg = NULL;
char buf[1024 * 5] = {0};
char *ptr_new = NULL;
char *pRecv = NULL;
int nRecv = 0;
int size_new = 0;
pFlg = flg;
pRecv = buf;
while ((nRecv = Recv(sockfd, pRecv, 1, 0)) == 1)
{
if (*pRecv == *pFlg)
{
++pFlg;
// find flag
if (pFlg - flg == len_flg)
{
size_new = *pack_len + (pRecv - buf) + 1;
ptr_new = (char*)realloc(*ut_buf, size_new);
if (ptr_new == NULL)
{
logdbg_fmt("recv_until_flag: realloc failed 1! size:%d\n", size_new);
return -1;
}
*ut_buf = ptr_new;
memcpy(*ut_buf + *pack_len, buf, (pRecv - buf) + 1);
*pack_len = size_new;
break;
}
}
else
{
pFlg = flg;
}
++pRecv;
}
return (nRecv <= 0) ? -1:1;
}
示例5: __RecvChangeName
bool CPythonNetworkStream::__RecvChangeName()
{
TPacketGCChangeName ChangeNamePacket;
if (!Recv(sizeof(TPacketGCChangeName), &ChangeNamePacket))
return false;
for (int i = 0; i < PLAYER_PER_ACCOUNT4; ++i)
{
if (ChangeNamePacket.pid == m_akSimplePlayerInfo[i].dwID)
{
m_akSimplePlayerInfo[i].bChangeName = FALSE;
strncpy(m_akSimplePlayerInfo[i].szName, ChangeNamePacket.name, CHARACTER_NAME_MAX_LEN);
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_SELECT], "OnChangeName", Py_BuildValue("(is)", i, ChangeNamePacket.name));
return true;
}
}
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_SELECT], "OnCreateFailure", Py_BuildValue("(i)", 100));
return true;
}
示例6: __AuthState_RecvChinaMatrixCard
bool CAccountConnector::__AuthState_RecvChinaMatrixCard()
{
TPacketGCChinaMatrixCard kMatrixCardPacket;
if (!Recv(sizeof(TPacketGCChinaMatrixCard), &kMatrixCardPacket))
return false;
if (m_poHandler)
{
PyObject * pyValue = Py_BuildValue("(iiiiiiii)", ROW(kMatrixCardPacket.dwRows, 0),
ROW(kMatrixCardPacket.dwRows, 1),
ROW(kMatrixCardPacket.dwRows, 2),
ROW(kMatrixCardPacket.dwRows, 3),
COL(kMatrixCardPacket.dwCols, 0),
COL(kMatrixCardPacket.dwCols, 1),
COL(kMatrixCardPacket.dwCols, 2),
COL(kMatrixCardPacket.dwCols, 3));
PyCallClassMemberFunc(m_poHandler, "OnMatrixCard", pyValue);
}
return true;
}
示例7: while
void Cube_SocketTCP_Connect::run()
{
int ssize;
Cube_SocketTCP_Connect_I _in;
while(TRUE)
{
if (ssize=recv(m_Client.s,(char *)_in.Buffer,CUBE_SOCKETTCP_I_BUFFERSIZE,0)==SOCKET_ERROR)
{
break;
}
if (ssize!=0)
{
Recv(_in);
}
else
{
break;
}
}
Offline();
}
示例8: main
int
main(int argc, char **argv)
{
int listenfd, connfd, n;
char buff[100];
fd_set rset, xset;
if (argc == 2)
listenfd = Tcp_listen(NULL, argv[1], NULL);
else if (argc == 3)
listenfd = Tcp_listen(argv[1], argv[2], NULL);
else
err_quit("usage: tcprecv02 [ <host> ] <port#>");
connfd = Accept(listenfd, NULL, NULL);
FD_ZERO(&rset);
FD_ZERO(&xset);
for ( ; ; ) {
FD_SET(connfd, &rset);
FD_SET(connfd, &xset);
Select(connfd + 1, &rset, NULL, &xset, NULL);
if (FD_ISSET(connfd, &xset)) {
n = Recv(connfd, buff, sizeof(buff)-1, MSG_OOB);
buff[n] = 0; /* null terminate */
printf("read %d OOB byte: %s\n", n, buff);
}
if (FD_ISSET(connfd, &rset)) {
if ( (n = Read(connfd, buff, sizeof(buff)-1)) == 0) {
printf("received EOF\n");
exit(0);
}
buff[n] = 0; /* null terminate */
printf("read %d bytes: %s\n", n, buff);
}
}
}
示例9: Data_Insert
/*
* @return: '0' to rollback, '1' to go head.
*/
int Data_Insert(int table_id, TupleId tuple_id, TupleId value, int nid)
{
int index;
int status;
uint64_t h;
DataRecord datard;
THREAD* threadinfo;
/* get the pointer to current thread information. */
threadinfo=(THREAD*)pthread_getspecific(ThreadInfoKey);
index=threadinfo->index;
/*
* the node transaction process must to get the data from the storage process in the
* node itself or in the other nodes, both use the socket to communicate.
*/
int lindex;
lindex = GetLocalIndex(index);
if ((Send3(lindex, nid, cmd_insert, table_id, tuple_id)) == -1)
printf("insert send error!\n");
if ((Recv(lindex, nid, 2)) == -1)
printf("insert recv error!\n");
status = *(recv_buffer[lindex]);
h = *(recv_buffer[lindex]+1);
if (status == 0)
return 0;
datard.type=DataInsert;
datard.table_id=table_id;
datard.tuple_id=tuple_id;
datard.value=value;
datard.index=h;
datard.node_id = nid;
DataRecordInsert(&datard);
return 1;
}
示例10: CTimeSpan
// Receives exactly Len bytes of data and returns the amount received - or SOCKET_ERROR if it times out
int CPassiveSock::ReceiveBytes(void * const lpBuf, const int Len)
{
int
bytes_received = 0,
total_bytes_received = 0;
RecvEndTime = CTime::GetCurrentTime() + CTimeSpan(0,0,0,TimeoutSeconds);
while (total_bytes_received < Len)
{
bytes_received = Recv((char*)lpBuf+total_bytes_received, Len-total_bytes_received);
if (bytes_received == SOCKET_ERROR)
return SOCKET_ERROR;
else if (bytes_received == 0)
break; // socket is closed, no data left to receive
else
{
total_bytes_received += bytes_received;
}
}; // loop
return (total_bytes_received);
}
示例11: Send
CPS_START_NAMESPACE
void GlobalDataShift::Shift(int mu, int n_disp){
if (n_disp==0) return;
SCUDir s_dir,r_dir;
int a_disp;
void *send_p,*recv_p,*temp_p;
if (n_disp>0){
a_disp = n_disp;
s_dir = gjp_scu_dir[mu*2];
r_dir = gjp_scu_dir[mu*2+1];
} else {
a_disp = -n_disp;
s_dir = gjp_scu_dir[mu*2+1];
r_dir = gjp_scu_dir[mu*2];
}
send_p = addr;
recv_p = temp_buf;
SCUDirArgIR Send(send_p,s_dir,SCU_SEND,data_len);
SCUDirArgIR Recv(recv_p,r_dir,SCU_REC,data_len);
sys_cacheflush(0);
for(int i = 0;i<a_disp-1;i++){
Send.StartTrans();Recv.StartTrans();
Send.TransComplete();Recv.TransComplete();
temp_p = send_p;
send_p = recv_p;
recv_p = temp_p;
Send.Addr(send_p);
Recv.Addr(recv_p);
}
Send.StartTrans();Recv.StartTrans();
Send.TransComplete();Recv.TransComplete();
if (recv_p != addr)
memcpy(addr,recv_p,data_len);
}
示例12: GL_RecvString
static void
GL_RecvString(
NETFILE *fp,
size_t maxsize,
char *str)
{
size_t lsize;
ENTER_FUNC;
lsize = GL_RecvLength(fp);
if ( maxsize >= lsize ){
Recv(fp,str,lsize);
if ( !CheckNetFile(fp) ) {
GL_Error();
}
str[lsize] = 0;
} else {
ShowErrorDialog(
_("GL_RecvString invalid size %ld > %ld(max size)"),
(unsigned long)lsize,(unsigned long)maxsize);
}
LEAVE_FUNC;
}
示例13: assert
void XShellProcess::run()
{
//Receive buffer size must be large than 3
assert(sizeof(m_RecvBuffer)>3);
DWORD dwRere=0;
while(TRUE)
{
if(m_hReadPipe1!=INVALID_HANDLE_VALUE&&m_bConsoleActivate)
{
PeekNamedPipe(m_hReadPipe1,m_RecvBuffer, sizeof(m_RecvBuffer),&m_lBytesRead,0,0);
if(m_lBytesRead)
{
memset(m_RecvBuffer, 0, sizeof(m_RecvBuffer));
if(ReadFile(m_hReadPipe1,m_RecvBuffer,sizeof(m_RecvBuffer)-2,&m_lBytesRead,0))
{
if (m_RecvBuffer[sizeof(m_RecvBuffer)-3]&0x80)
{
if(!ReadFile(m_hReadPipe1,m_RecvBuffer+sizeof(m_RecvBuffer)-2,1,&dwRere,0))
break;
}
XShellProcess_I In;
In.Buffer=m_RecvBuffer;
In.size=m_lBytesRead+dwRere;
Recv(In);
}
}
else
{
Sleep(300);
}
}
else
{
Sleep(300);
}
}
}
示例14: RecvSafeBoxSetPacket
bool CPythonNetworkStream::RecvSafeBoxSetPacket()
{
TPacketGCItemSet2 kItemSet;
if (!Recv(sizeof(kItemSet), &kItemSet))
return false;
TItemData kItemData;
kItemData.vnum = kItemSet.vnum;
kItemData.count = kItemSet.count;
kItemData.flags = kItemSet.flags;
kItemData.anti_flags = kItemSet.anti_flags;
for (int isocket=0; isocket<ITEM_SOCKET_SLOT_MAX_NUM; ++isocket)
kItemData.alSockets[isocket] = kItemSet.alSockets[isocket];
for (int iattr=0; iattr<ITEM_ATTRIBUTE_SLOT_MAX_NUM; ++iattr)
kItemData.aAttr[iattr] = kItemSet.aAttr[iattr];
CPythonSafeBox::Instance().SetItemData(kItemSet.Cell.cell, kItemData);
__RefreshSafeboxWindow();
return true;
}
示例15: hpvc_client_thread
void * hpvc_client_thread(void * p)
{
int avfd;
char buf[512];
int len;
while(1)
{
if( -1 != hpvc_client_init())
{
while(1)
{
len = Recv(hpvcfd , buf , 512 , 0);
if(len == 0)
{
fprintf(stderr , "mgrIhpvc recv == 0\n");
close(hpvcfd);
hpvcfd = -1;
break;
// exit(-1);
}
hpvcmgr_defifo(&hpvc_usr);
avfd = *((int *)hpvc_usr.p);
fprintf(stderr , "recv hpvcmgr reply , pktlen : %d , pkttype : %d , reserve %d , dspnum : %d , avfd : %d\n" ,
htons(*((short*)buf)) , htons(*((short*)(buf + 2))) , htons(*(short*)(buf + 4)) , htonl(*(int*)(buf + 6)) , avfd);
send(avfd , buf , len , 0);
}
}
else
{
sleep(5);
continue;
}
hpvcmgr_destroy_memdata(&hpvc_usr.mem_list);
sleep(1);
}
}