• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Accept函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: P2PAccept

int P2PAccept(int Sockfd, struct sockaddr_in Dest, void(*Function) (void*), void* Arg){
    if(List != NULL){                                               //  如果链表为空
        LinkC_Debug("P2PAccept:LinkC Socket环境没有初始化",LINKC_FAILURE);
        return LINKC_FAILURE;                                       //  返回错误
    }
    LinkC_Socket *Socket = NULL;
    if(IsSocketInList(Sockfd,&Socket)==0){
        LinkC_Debug("P2PAccept:没有这个套接字",LINKC_FAILURE);
        return -1;
    }
    EmptyPackageList(Socket->RecvList);         //  清空发送和接收缓冲区
    EmptyPackageList(Socket->SendList); 
    SetDestAddr(Sockfd,Dest);
    int Length = _LCUDP_Package(NULL,0,Socket,CONNECTION_MESSAGE,Socket->SendBuffer);
    ___LinkC_Send(Socket,Socket->SendBuffer,Length,MSG_DONTWAIT);
    if(Function != NULL){                                   //  执行函数,这里是我发送了无用信息后向服务端确认
        Function(Arg);
    }
    Accept(Sockfd,Dest);
    
    return 0;
}
开发者ID:ExAnthon,项目名称:LinkC,代码行数:22,代码来源:linkc_network_UDP_system.cpp


示例17: main

int main()
{
    int listen_sid = Listen(1); // listen on port 1;

    int socket_accept, socket_connect;

    socket_accept = Accept(listen_sid);

    char buf[6];

    Receive(socket_accept, buf, 6, 1);

    PutString(" Machine 1 has the : ");
    PutString(buf); // should be totem
    PutChar('\n');

    socket_connect = Connect(2,1); // machine i+1

    Send(socket_connect, "TOTEM", 6);

    return 0;
}
开发者ID:sparklusive,项目名称:project-system,代码行数:22,代码来源:step6_ring_member.c


示例18: main

int main(int argc, char *argv[])
{
    int sockfd = Socket(AF_INET,SOCK_STREAM,0); 
    struct sockaddr_in servaddr;
    servaddr.sin_port = htons(SERV_PORT);
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr = INADDR_ANY;
    socklen_t servlen = sizeof(servaddr);
    Bind(sockfd, (struct sockaddr*) &servaddr, servlen);
    Listen(sockfd, SOMAXCONN);
    int clifd;
    for(; ; )
    {
       clifd = Accept(sockfd, NULL, NULL);  
       if(clifd != -1)
       {
            pid_t child = Fork();
            if(child == 0)
            {
                Close(sockfd);
                printf("create child process success! \n");     
                break;
            }
            else
            {
                printf("child process pid [%d]", child);

            }
       }
    }
    // echo server
    char buff[1024];
    while(1)
    {
        Read(clifd,buff, 1024); 
        Write(clifd, buff, strlen(buff));
    }
    return 0;
}
开发者ID:yulingjie,项目名称:Net,代码行数:39,代码来源:tcpserv.c


示例19: connect

void CManageFileTransfer::slotFileReceived(const QString& szId, QSharedPointer<CFileTransfer> file)
{
    bool check = connect(file.data(), SIGNAL(sigFinished(const QString&, const QString&)),
                         SLOT(slotFinished(const QString&, const QString&)));
    Q_ASSERT(check);
    m_FileTransfer.insertMulti(szId, file);
    QSharedPointer<CUser> roster = GLOBAL_USER->GetUserInfoRoster(szId);
    if(roster.isNull())
    {
        LOG_MODEL_ERROR("CManageFileTransfer", "There isn't roster:%s", szId.toStdString().c_str());
        return;
    }

    if(CTool::isImageFile(file->GetFile()))
    {
        Accept(file);
    }
    QSharedPointer<CFileTransferAction> action(new CFileTransferAction(file, szId, QTime::currentTime(), false));
    roster->GetMessage()->AddMessage(action);
    GET_MAINWINDOW->ShowTrayIconMessage(roster->GetInfo()->GetShowName() + ":", tr("Send file %1").arg(file->GetFile()));
    emit GET_CLIENT->sigMessageUpdate(szId);
}
开发者ID:corefan,项目名称:rabbitim,代码行数:22,代码来源:ManageFileTransfer.cpp


示例20: main

int main(int argc, char **argv) 
{
    int i, listenfd, connfd, port, clientlen=sizeof(struct sockaddr_in);
    struct sockaddr_in clientaddr;
    pthread_t tid; 

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

    for (i = 0; i < NTHREADS; i++)  /* Create worker threads */
	Pthread_create(&tid, NULL, thread, NULL);

    while (1) { 
	connfd = Accept(listenfd, (SA *) &clientaddr, &clientlen);
	sbuf_insert(&sbuf, connfd); /* Insert connfd in buffer */
    }
}
开发者ID:09zwcbupt,项目名称:csapp,代码行数:22,代码来源:echoservert_pre.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AccountTypes函数代码示例发布时间:2022-05-30
下一篇:
C++ Absolute函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap