📄 rvtransport.h
字号:
/******************************************************************************
Filename: rvtransport.h
Description: class used to receive complete packets from a group of sockets.
*******************************************************************************
Copyright (c) 2000 RADVision Inc.
*******************************************************************************
NOTICE:
This document contains information that is proprietary to RADVision Inc.
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVision Inc.
RADVision Inc. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.
******************************************************************************/
#ifndef RV_TRANSPORT_H
#define RV_TRANSPORT_H
#include "rvtypes.h"
#include "rvsocketengine.h"
#include "rvqueue.h"
#if defined(__cplusplus)
extern "C" {
#endif
/* transport initialization and shutdown */
RvBool rvTransportInit(void);
void rvTransportEnd(void);
typedef enum
{
RV_TRANSPORTTYPE_UDP,
RV_TRANSPORTTYPE_TCP
} RvTransportType;
typedef void (*RvRecvPacketCb)(char *packet, size_t length, RvSocket *socket, RvSocketAddr *fromAddr, RvTransportType type, void *data);
typedef void (*RvSocketDeleteCb)(RvSocket *socket, void *data);
typedef struct
{
RvSocketEngine socketEngine;
RvQueue packetQueue;
size_t numThreads;
RvThread *threads;
RvRecvPacketCb processPacket;
size_t callbacksPending;
RvSocketDeleteCb onSocketDelete;
RvAlloc *genAlloc, *recvBufAlloc;
} RvTransport;
RvTransport *rvTransportConstruct(RvTransport *x, RvRecvPacketCb f,
size_t numThreads, int priority, RvAlloc *genAlloc, RvAlloc *recvBufAlloc);
void rvTransportDestruct(RvTransport *x);
/* Call these functions to add sockets to the transport.
Received packets will be sent to the RvRecvPacketCb callback.
The returned RvSocket pointers can be passed to rvTransportRemoveSocket
to remove the socket from the transport. The socket pointers returned
from rvTransportAddUdpSocket and rvTransportAddTcpActive can
also be used to send packets. */
RvSocket *rvTransportAddUdpSocket(RvTransport *x, RvInetPort port, void *data);
RvSocket *rvTransportAddTcpPassive(RvTransport *x, RvInetPort port, void *data);
RvSocket *rvTransportAddTcpActive(RvTransport *x, RvSocketAddr *addr, void *data);
void rvTransportRemoveSocket(RvTransport *x, RvSocket *socket);
RvSocketListener *rvTransportUnregisterSocket(RvTransport *x, RvSocket *socket);
void rvTransportRemoveUnregisteredSocket(RvTransport *x, RvSocket *socket, RvSocketListener *sl);
/* start or stop receiving packets */
void rvTransportStart(RvTransport *x);
void rvTransportStop(RvTransport *x);
/* register callback invoked when socket is deleted */
void rvTransportRegisterSocketDeleteCb(RvTransport *x, RvSocketDeleteCb f);
#if defined(__cplusplus)
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -