Ejemplo n.º 1
0
void
WebRtcEndpointImpl::createDataChannel (const std::string &label, bool ordered,
                                       int maxPacketLifeTime, int maxRetransmits)
{
  createDataChannel (label, ordered, maxPacketLifeTime, maxRetransmits, "");
}
Ejemplo n.º 2
0
void
WebRtcEndpointImpl::createDataChannel (const std::string &label, bool ordered)
{
  createDataChannel (label, ordered, -1, -1, "");
}
Ejemplo n.º 3
0
void
WebRtcEndpointImpl::createDataChannel ()
{
  createDataChannel ("", true, -1, -1, "");
}
Ejemplo n.º 4
0
void
WebRtcEndpointImpl::createDataChannel (const std::string &label)
{
  createDataChannel (label, true, -1, -1, "");
}
Ejemplo n.º 5
0
void logPacketTCP(int newSockSignal, ofstream *out)
{
	
	int port;

	
	int newSockLog;

	
	struct sockaddr_in sockAddress;

	
	struct sockaddr_in srcAddress;

	

	
	int logSock, hold, hold2, dim2;

	
	struct info *infos = (struct info *) malloc(logbuffer_size * sizeof(info));
	char *infosOffset;

	
	socklen_t sinLen = sizeof(srcAddress);

	

	
	fd_set activeSet;

	int	dim_infos;

#ifdef DEBUG
	
    int numRecvdPkt=0;

	
    int numTrip=0;
#endif

	

	
	sockAddress.sin_family = AF_INET;
	
	sockAddress.sin_addr.s_addr = htonl(INADDR_ANY);

	

	createDataChannel(sockAddress,newSockSignal,logSock,port,"TCP");

	
	if (listen(logSock, 5) < 0)
		reportErrorAndExit("logPacketTCP","listen","Error into listen on logSock");
	

	
	newSockLog = accept(logSock, (struct sockaddr *) &srcAddress, &sinLen);
	PRINTD(1,"logPacketTCP: newSockLog TCP : %d \n",newSockLog);
	if (newSockLog < 0)
		reportErrorAndExit("logPacketTCP","accept","Error into accept on logSock");

	
	while (1) {
		
		FD_ZERO(&activeSet);
		
		FD_SET((unsigned int)newSockSignal, &activeSet);
		
		FD_SET((unsigned int)newSockLog, &activeSet);

		
		if (select(FD_SETSIZE, &activeSet, NULL, NULL, 0) < 0)
			reportErrorAndExit("logPacketTCP","select",
			"Invalid file descriptor or operation interrupted by a signal - Close first Receiver");
		
		if (FD_ISSET(newSockSignal, &activeSet)) {
			
			break;
		
		} else if (FD_ISSET(newSockLog, &activeSet)) {
			
			
			dim2 = logbuffer_size * sizeof(struct info);
			hold = 0;
			infosOffset = (char *)infos;
			do {
				hold2 = recv(newSockLog, (char *)infosOffset, dim2, 0);
				hold += hold2;
				dim2 -= hold2;
				infosOffset += hold2;
			} while (((hold % sizeof(struct info)) != 0) && (hold2 >= 0));

			if (hold < 0)
				
				printf("** WARNING **  Data lost - Close First Receiver!\n");
			else {
				
				dim_infos = hold / sizeof(struct info);
				infosntoh(infos, dim_infos); 
				
#ifdef DEBUG
           			numRecvdPkt = numRecvdPkt + hold / sizeof(struct info);
				numTrip++;
#endif
				
				if (!(*out).write((char *) infos, hold))
					printf("** WARNING **  Can't write data!\n");
			}
		}
	}

#ifdef DEBUG
	
	char hostName[50];
	
	char hostIP[20];
	int rit1 = getnameinfo((sockaddr*)&senderLog,sizeof(senderLog),hostName, INET_ADDRSTRLEN, NULL, 0,
			NI_NOFQDN);
	int rit2 = getnameinfo((sockaddr*)&senderLog,sizeof(senderLog),hostIP, INET_ADDRSTRLEN, NULL, 0,
			NI_NUMERICHOST);
	if ((rit1 == 0) & (rit2 == 0))
		printf("Data transmission ended on TCP channel from %s(%s)\n",hostName,hostIP);
	else if ((rit1 != 0) & (rit2 == 0))
			printf("Data transmission ended on TCP channel from %s\n",hostIP);
	else
#endif
	printf("Data transmission ended on TCP channel!\n");
	fflush(stdout);

	
	free(infos);
	if (closeSock(logSock) < 0)
		reportErrorAndExit("logPacketTCP","closeSock","Cannot close logSock");
	if (closeSock(newSockLog) < 0)
		reportErrorAndExit("logPacketTCP","closeSock","Cannot close newLogSock");
	PRINTD(1,"logPacketTCP: Number of received packets : %d \n",numRecvdPkt);
	PRINTD(1,"logPacketTCP: Number of received infos : %d \n",numTrip);
}