Prev: Programming UI-based shell/Terminal programs
Next: open all bloced sites with free proxy service facebook,myspace,twitter ......etc
From: Bill Cunningham on 18 May 2010 17:16 "Bill Cunningham" <nospam(a)nspam.invalid> wrote in message news:4bf1cebf$0$11808$bbae4d71(a)news.suddenlink.net... [snip]int status; struct addrinfo hints; struct addrinfo *servinfo; // will point to the results memset(&hints, 0, sizeof hints); // make sure the struct is empty hints.ai_family = AF_UNSPEC; // don't care IPv4 or IPv6 hints.ai_socktype = SOCK_STREAM; // TCP stream sockets hints.ai_flags = AI_PASSIVE; // fill in my IP for me if ((status = getaddrinfo(NULL, "3490", &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(status)); exit(1); } // servinfo now points to a linked list of 1 or more struct addrinfos // ... do everything until you don't need servinfo anymore .... freeaddrinfo(servinfo); // free the linked-listNotice in this example, NULL is passed to getaddrinfo().Bill
From: Bill Cunningham on 18 May 2010 17:26 "Bill Cunningham" <nospam(a)nspam.invalid> wrote in message news:4bf30330$0$11847$bbae4d71(a)news.suddenlink.net... [snip] > I believe you are right in some cases. Any concerning a client socket. > But I have passed NULL to parameter 1 of getaddrinfo() before and had no > problem but certain conditions must be met. I can't remember right off the > top of my head because I haven't done this in a while. As far as my > client() function goes I am passing to its first parameter a NULL yes. The > second paramter of the getaddrinfo function always must be a port number. > > Bill If node is NULL, the network address in each socket structure is initialized according to the AI_PASSIVE flag, which is set in hints.ai_flags. The network address in each socket structure will be left unspecified if AI_PASSIVE flag is set. This is used by server applications, which intend to accept client connections on any network address. The network address will be set to the loopback interface address if the AI_PASSIVE flag is not set. This is used by client applications, which intend to connect to a server running on the same network host. http://linux.die.net/man/3/getaddrinfo
From: Bill Cunningham on 18 May 2010 18:32 "Scott Lurndal" <scott(a)slp53.sl.home> wrote in message news:rABIn.52890$y07.52111(a)news.usenetserver.com... > You are passing NULL as the arg to client, which is then passed as the > 'node' argument to getaddrinfo. Getaddrinfo will segfault if you pass > NULL as the node argument, which should be either the hostname or > dotted-quad > IP address for the server. I don't quite have my separations between client and server code down. Have to con't with Steven's book. Bill
From: Ian Collins on 18 May 2010 18:34 On 05/19/10 10:32 AM, Bill Cunningham wrote: > "Scott Lurndal"<scott(a)slp53.sl.home> wrote in message > news:rABIn.52890$y07.52111(a)news.usenetserver.com... > >> You are passing NULL as the arg to client, which is then passed as the >> 'node' argument to getaddrinfo. Getaddrinfo will segfault if you pass >> NULL as the node argument, which should be either the hostname or >> dotted-quad >> IP address for the server. > > I don't quite have my separations between client and server code down. > Have to con't with Steven's book. Still fumbling in the dark Bill? Or are you having us on? -- Ian Collins
From: Bill Cunningham on 18 May 2010 20:57
"Ian Collins" <ian-news(a)hotmail.com> wrote in message news:85gj0eFingU2(a)mid.individual.net... > Still fumbling in the dark Bill? Or are you having us on? > Don't freak out Ian. I'm only in the first 50 pages of Unix network programing. Remember I'm not a computer scientist. I can't compete. I hope if you're that suspicious a person that you don't think I'm a CS in disguise asking lame questions. But I think the sun will rise tomorrow and the world will continue. Bill |