Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 46527 Details for
Bug 75159
portageq executed for every line of output, slow
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
c client for portageqd
portageq.c (text/plain), 1.77 KB, created by
Daniel Lawson
on 2004-12-21 03:18:26 UTC
(
hide
)
Description:
c client for portageqd
Filename:
MIME Type:
Creator:
Daniel Lawson
Created:
2004-12-21 03:18:26 UTC
Size:
1.77 KB
patch
obsolete
>/* > ** client.c -- a stream socket client demo > */ > >#include <stdio.h> >#include <stdlib.h> >#include <unistd.h> >#include <errno.h> >#include <string.h> >#include <netdb.h> >#include <sys/types.h> >#include <netinet/in.h> >#include <sys/socket.h> > > >#define BUFSIZE 65536 // max number of bytes we can get at once > >#define BUFLEFT packetbuf + BUFSIZE - scan > >char *hostname = "localhost"; >short port = 21567; >int main(int argc, char *argv[]) >{ > int sockfd, numbytes; > char buf[BUFSIZE]; > char *packetbuf = (char *)calloc(1,BUFSIZE); > char *scan = packetbuf; > struct hostent *he; > struct sockaddr_in their_addr; // connector's address information > int i = 0; > if (argc == 1) { > fprintf(stderr,"usage: %s portageoption [parameter ... ]\n"); > exit(1); > } > > if ((he=gethostbyname(hostname)) == NULL) { // get the host info > perror("gethostbyname"); > exit(1); > } > > if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { > perror("socket"); > exit(1); > } > > their_addr.sin_family = AF_INET; // host byte order > their_addr.sin_port = htons(port); // short, network byte order > their_addr.sin_addr = *((struct in_addr *)he->h_addr); > memset(&(their_addr.sin_zero), '\0', 8); // zero the rest of the struct > > if (connect(sockfd, (struct sockaddr *)&their_addr, > sizeof(struct sockaddr)) == -1) { > perror("connect"); > exit(1); > } > for (i = 1; i < argc; i++) { > scan += snprintf(scan,BUFLEFT,"%s ",argv[i]); > } > if ((numbytes=send(sockfd, packetbuf, strlen(packetbuf),0)) == -1) { > perror("send"); > exit(1); > } > > if ((numbytes=recv(sockfd, buf, BUFSIZE-1, 0)) == -1) { > perror("recv"); > exit(1); > } > > if (strlen(buf) == 1) { > if (!strncmp(buf,"0",1)) { > exit(0); > } else if (!strncmp(buf,"1",1)) { > exit(1); > } > } > buf[numbytes] = '\0'; > > printf("%s\n",buf); > > close(sockfd); > > return 0; >} > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 75159
:
46526
| 46527