当前位置: 首页>>代码示例>>C++>>正文


C++ Accept函数代码示例

本文整理汇总了C++中Accept函数的典型用法代码示例。如果您正苦于以下问题:C++ Accept函数的具体用法?C++ Accept怎么用?C++ Accept使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Accept函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tinyHttpServer

int tinyHttpServer(int argc, char** argv) {
    int listenfd, connfd, port, clientlen, logfd;
    struct sockaddr_in clientaddr;
    logfd = open("./runtimelog.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRWXO);
    runtimeLogFmt("logfd is %d\n", logfd);

    if (argc != 2) {
        fprintf(stderr, "usage: %s <port>\n", argv[0]);
        exit(1);
    }
    port = atoi(argv[1]);

    listenfd = Open_listenfd(port);
    while (1) {
        clientlen = sizeof(clientaddr);
        connfd = Accept(listenfd, (SA *)&clientaddr, (socklen_t *)&clientlen);
        runtimeLogFmt("enter doit()\n");
        doit(connfd);
        Close(connfd);
    }
}
开发者ID:DeathPoem,项目名称:Practice,代码行数:21,代码来源:main.c

示例2: SetParallel

    virtual void SetParallel (void)     // overload virtual
    {
      Trafo A; 
      float fov, newfov = 1.0;
      GetSelectionView(A,fov);

      // Reduce the field of view angle fov to 1 degree 
      // scaling the z-coordinate of the translation part of the 
      // transformation matrix A(2,3) to make the image appear the
      // same size.
      A(2,3) *= tan(DegToRad(fov)) / tan(DegToRad(newfov));

      SetSelectionView(A,newfov,
                       view->GetActiveGraphPtr()->vbx,
                       view->GetActiveGraphPtr()->vby,
                       view->GetActiveGraphPtr()->vbz);
      Accept();

      // finally always call method of base class of view panel for update
      view->display->Viewport3DPanel->MpViewPanel::Accept();
    }
开发者ID:lucafuji,项目名称:Gene-Correlation,代码行数:21,代码来源:mpviewport3d.cpp

示例3: switch

int MyServer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateTextBrowser((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 1: updateTextBrowserDlg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 2: addtoListWidget((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 3: deletefromListWidget((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 4: Service(); break;
        case 5: Accept(); break;
        case 6: DisplayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break;
        case 7: OnDisconnected(); break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}
开发者ID:kref,项目名称:mobileim,代码行数:21,代码来源:moc_myserver.cpp

示例4: main

int main(int argc, char **argv) 
{
    int listenfd, connfd, port, clientlen;
    struct sockaddr_in clientaddr;

    /* Check command line args */
    if (argc != 2) {
	fprintf(stderr, "usage: %s <port>\n", argv[0]);
	exit(1);
    }
    port = atoi(argv[1]);

    listenfd = Open_listenfd(port);
    while (1) {
	clientlen = sizeof(clientaddr);
	connfd = Accept(listenfd, (SA *)&clientaddr, &clientlen); //line:netp:tiny:accept
	//echo(connfd);
	doit(connfd);                                             //line:netp:tiny:doit
	Close(connfd);                                            //line:netp:tiny:close
    }
}
开发者ID:Zak-Olyarnik,项目名称:CS-283,代码行数:21,代码来源:server.c

示例5: Accept

void CServerSocket::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	//接收客户端连接
    CSocket client;
	Accept(client);
	//收发数据

    //接收数据包的包头
	HEADER header={0};
    RecvData(client,(BYTE*)&header,sizeof(header));
	//根据包头中的文件路径构造文件的服务器路径
     CString strFileName=header.szFile;
	 int nFind=strFileName.ReverseFind('\\');
     strFileName=strFileName.Mid(nFind+1);
	 CString strPath="c:\\"+strFileName;
	 AfxMessageBox(strPath);
	//根据包头中的文件长度,接受文件数据
    RecvFile(client,strPath,header.nLen);
	CAsyncSocket::OnAccept(nErrorCode);
}
开发者ID:soplist,项目名称:study-c-cpp,代码行数:21,代码来源:ServerSocket.cpp

示例6: main

int main(int argc, char **argv)
{
	int listenfd, connfd, port, clientlen;
	struct sockaddr_in clientaddr;

	if(argc !=2)
	{
		fprintf(stderr, "usage: %s <port>\n",argv[0]);
		exit(1);
	}
	port = atoi(argv[1]);

	listenfd = Open_listenfd(port);
	while(1)//无线服务器循环
	{
		clientlen = sizeof(clientaddr);
		connfd = Accept(listenfd, (SA*)&clientaddr, &clientlen);
		doit(connfd);//执行事务
		Close(connfd);
	}
}
开发者ID:zhangyuguo001,项目名称:Tiny_Web_Server,代码行数:21,代码来源:tiny.c

示例7: child_main

void
child_main(int i, int listenfd, int addrlen)
{
	int				connfd;
	void			web_child(int);
	socklen_t		clilen;
	struct sockaddr	*cliaddr;

	cliaddr = Malloc(addrlen);

	printf("child %ld starting\n", (long) getpid());
	for ( ; ; ) {
		clilen = addrlen;
		my_lock_wait();
		connfd = Accept(listenfd, cliaddr, &clilen);
		my_lock_release();

		web_child(connfd);		/* process the request */
		Close(connfd);
	}
}
开发者ID:elftech,项目名称:vmware-code,代码行数:21,代码来源:child04.c

示例8: Open_Buffer_Init

//---------------------------------------------------------------------------
void File_ChannelGrouping::Read_Buffer_Init()
{
    if (Common==NULL)
    {
        Common=new common;
        Common->Parser=new File_Aes3;
        ((File_Aes3*)Common->Parser)->SampleRate=SampleRate;
        ((File_Aes3*)Common->Parser)->ByteSize=ByteDepth*Channel_Total;
        ((File_Aes3*)Common->Parser)->IsAes3=IsAes3;
        Common->Channels.resize(Channel_Total);
        for (size_t Pos=0; Pos<Common->Channels.size(); Pos++)
            Common->Channels[Pos]=new common::channel;
        Element_Code=(int64u)-1;
        Open_Buffer_Init(Common->Parser);
    }

    Accept(); //Forcing acceptance, no possibility to choose something else or detect PCM
    #if MEDIAINFO_DEMUX
         Demux_UnpacketizeContainer=Config->Demux_Unpacketize_Get();
    #endif //MEDIAINFO_DEMUX
}
开发者ID:Dimetro83,项目名称:DC_DDD,代码行数:22,代码来源:File_ChannelGrouping.cpp

示例9: while

//---------------------------------------------------------------------------
bool File_DvbSubtitle::Synchronize()
{
    //Synchronizing
    if (MustFindDvbHeader)
    {
        while(Buffer_Offset+3<=Buffer_Size)
        {
            if (Buffer[Buffer_Offset]==0x20
             && Buffer[Buffer_Offset+1]==0x00
             && (Buffer[Buffer_Offset+2]==0x0F
              || Buffer[Buffer_Offset+1]==0xFF))
                break;
            Buffer_Offset++;
        }

        if (Buffer_Offset+3>Buffer_Size)
            return false;

        Accept();
    }
    else
    {
        while(Buffer_Offset<Buffer_Size)
        {
            if (Buffer[Buffer_Offset]==0x0F
             || Buffer[Buffer_Offset]==0xFF)
                break;
            Buffer_Offset++;
        }

        if (Buffer_Offset>=Buffer_Size)
            return false;
    }

    //Synched is OK
    Synched=true;
    if (!Frame_Count_Valid)
        Frame_Count_Valid=Config->ParseSpeed>=0.3?32:2;
    return true;
}
开发者ID:MediaArea,项目名称:MediaInfoLib,代码行数:41,代码来源:File_DvbSubtitle.cpp

示例10: Get_L1

//---------------------------------------------------------------------------
void File_Ico::Data_Parse()
{
    //Parsing
    int32u Size, Offset;
    int16u BitsPerPixel;
    int8u Width, Height;
    Get_L1 (Width,                                      "Width");
    Get_L1 (Height,                                     "Height");
    Skip_L1(                                            "Colour count");
    Skip_L1(                                            "Reserved");
    Skip_L2(                                            Type==1?"Colour planes":"X hotspot");
    Get_L2 (BitsPerPixel,                               Type==1?"Bits per pixel":"Y hotspot");
    Get_L4 (Size,                                       "Size of the bitmap data");
    Get_L4 (Offset,                                     "Offset of the bitmap data");

    FILLING_BEGIN_PRECISE();
        stream Stream;
        Stream.Width=Width;
        Stream.Height=Height;
        Stream.BitsPerPixel=BitsPerPixel;
        Stream.Size=Size;
        Stream.Offset=Offset;
        Streams.push_back(Stream);

        IcoDataSize+=Size;
        if (Offset>File_Size || File_Offset+Buffer_Offset+Element_Size+IcoDataSize>File_Size)
            Reject("ICO");
        Count--;
        if (Count==0)
        {
            if (File_Offset+Buffer_Offset+Element_Size+IcoDataSize!=File_Size)
                Reject("ICO");
            else
            {
                Accept("ICO");
                Finish("ICO");
            }
        }
    FILLING_END();
}
开发者ID:asfdfdfd,项目名称:MediaInfoLib-Avdump2-Mac,代码行数:41,代码来源:File_Ico.cpp

示例11: Get_UTF8

//---------------------------------------------------------------------------
void File_TimedText::Data_Parse()
{
    //Parsing
    Ztring Value;
    Get_UTF8 (Element_Size, Value,                              "Value");

    FILLING_BEGIN();
        if (!Status[IsAccepted])
        {
            Accept();
            #ifdef MEDIAINFO_MPEG4_YES
                if (IsChapter)
                {
                    Stream_Prepare(Stream_Menu);
                }
                else
            #endif //MEDIAINFO_MPEG4_YES
                {
                    Stream_Prepare(Stream_Text);
                }
            Fill(StreamKind_Last, 0, Fill_Parameter(StreamKind_Last, Generic_Format), "Timed Text");
        }
        #ifdef MEDIAINFO_MPEG4_YES
            if (IsChapter)
            {
            }
            else
        #endif //MEDIAINFO_MPEG4_YES
            {
                Finish();
            }

        #ifdef MEDIAINFO_MPEG4_YES
            if (IsChapter && FrameInfo.DTS!=(int64u)-1 && Buffer_Offset==2)
                Fill(Stream_Menu, 0, Ztring().Duration_From_Milliseconds(FrameInfo.DTS/1000000).To_UTF8().c_str(), Value);
        #endif //MEDIAINFO_MPEG4_YES
    FILLING_END();

    Element_Offset=Buffer_Size-Buffer_Offset; //Buffer can also contain atoms after the text, ignoring them
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:41,代码来源:File_TimedText.cpp

示例12: main

int
main(int argc, char** argv)
{
	int fd, optval, cfd;
	struct sockaddr_in6 server_addr, client_addr;
	socklen_t addr_len, client_addr_len;
	time_t ticks;
	char buf[BUFFER_SIZE];

	fd = Socket(AF_INET6, SOCK_STREAM, 0);
	optval = 1;
	setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval);
	optval = 0;
	setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof optval);
	memset((void *) &server_addr, 0, sizeof(server_addr));
	server_addr.sin6_family = AF_INET6;
#ifdef HAVE_SIN_LEN
	server_addr.sin6_len = sizeof(struct sockaddr_in6);
#endif
	server_addr.sin6_addr = in6addr_any;
	server_addr.sin6_port = htons(atoi(argv[1]));
	
	Bind(fd, (const struct sockaddr *) &server_addr, sizeof(server_addr));
	Listen(fd, 1);
	for (;;) {
		memset((void *) buf, '\0', sizeof(buf));
		addr_len = (socklen_t) sizeof(client_addr);
		memset((void *) &client_addr, 0, sizeof(client_addr));
		client_addr_len = (socklen_t) sizeof(client_addr);
		cfd = Accept(fd, (struct sockaddr *) &client_addr, &client_addr_len);
		ticks = time(NULL);
		snprintf(buf, sizeof(buf), "%.24s\r\n", ctime(&ticks));
		printf("%ld\r\n", strlen(buf));
		Sendto(cfd, (void *) buf, strlen(buf), 0, (struct sockaddr *)&client_addr, client_addr_len);
		Close(cfd);
	}
	Close(fd);

	return(0);
}
开发者ID:frenos,项目名称:inteng,代码行数:40,代码来源:daytime_server.c

示例13: main

int
main(int argc, char **argv) {

    int listenfd, connfd;
    socklen_t len;
    struct sockaddr_in servaddr, cliaddr;
    char buff[MAXLINE];
    time_t ticks;

    listenfd = Socket(AF_INET, SOCK_STREAM, 0);

    bzero(&servaddr, sizeof (servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
    servaddr.sin_port = htons(9997); /* test*/

    Bind(listenfd, (SA *) & servaddr, sizeof (servaddr));

    Listen(listenfd, LISTENQ);
    puts("listening...");

    for (;;) {
        len = sizeof (cliaddr);
        connfd = Accept(listenfd, (SA *) & cliaddr, &len);
        printf( "connection from %s, port %d\n",
                Inet_ntop(AF_INET, &cliaddr.sin_addr, buff, sizeof (buff)),
                ntohs(cliaddr.sin_port));

        ticks = time(NULL);
        snprintf(buff, sizeof (buff), "%.24s\r\n", ctime(&ticks));

        //Write(connfd, buff, strlen(buff)); // normal version, write at once
        int i; // call Write for each one byte
        for (i = 0; i < strlen(buff); ++i) {
            Write(connfd, &buff[i], 1);
        }
        printf( "writes: %d\n", i);
        Close(connfd);
    }
}
开发者ID:bharathvu,项目名称:unix_networking_projects,代码行数:40,代码来源:daytimeserver_1.c

示例14: 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);
		}
	}
}
开发者ID:elftech,项目名称:vmware-code,代码行数:40,代码来源:tcprecv02.c

示例15: main

int main(int argc, char **argv)
{
	if (argc != 2)
	{
		fprintf(stderr, "usage: %s <port>\n", argv[0]);
		exit(1);
	}
	int listenfd, clientlen, port;
	int *connfd;
	struct sockaddr_in clientaddr;
	pthread_t tid;

  //pthread_rwlock_init(&host_lock, NULL);
  pthread_rwlock_init(&lock, NULL);

	//Ignore any sigpipe signals
	Signal(SIGPIPE, SIG_IGN);

  init_cache();
	//get port number
	port = atoi(argv[1]);

	//start listening on the specified port number
	listenfd = Open_listenfd(port);


	while (1)
	{
		clientlen = sizeof(clientaddr);
		connfd = malloc(sizeof(int));
		//accept the connection 
		*connfd = Accept(listenfd,(SA *)&clientaddr,(unsigned int *)&clientlen);

		//create a thread and run execute thread
		Pthread_create(&tid, NULL, executeT, connfd);
	}
    

    return 0;
}
开发者ID:shilpamurthy,项目名称:HTTP-Proxy-server,代码行数:40,代码来源:proxy.c


注:本文中的Accept函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。