Re: Macnetworkprog Digest, Vol 1, Issue 74
Re: Macnetworkprog Digest, Vol 1, Issue 74
- Subject: Re: Macnetworkprog Digest, Vol 1, Issue 74
- From: Mike Cohen <email@hidden>
- Date: Thu, 16 Dec 2004 21:10:43 -0500
You can mix them with carbon. CFSocket is a wrapper for low-level
sockets. You can obtain the socket descriptor and use standard socket
calls with it. You can also initialize a CFSocket with an existing
socket.
On Dec 16, 2004, at 9:03 PM, Ryan M Joseph wrote:
So these functions are only available in the terminal? I was wanting
to use them in conjunction with CFSocket in a carbon project. Do these
headers not exist with any library or a framework etc...? I was
reading over the darwin docs on apples site and it appears they are a
part on an independent programing environment, which can not work in
conjunction with carbon?
On Thursday, December 16, 2004, at 02:51 PM, Mike Cohen wrote:
It isn't visible in the finder, only in the terminal
On Dec 16, 2004, at 4:40 PM, Ryan M Joseph wrote:
Huh, I just ran search for that file and did not see it, nor have I
ever seen the "usr" folder. I'm running 10.2, it must be there. Do
you know where it can be found?
On Thursday, December 16, 2004, at 02:26 PM, Mike Cohen wrote:
It's a BSD function defined /usr/include/netdb.h
In the terminal, the doc is available via 'man gethostbyname'.
Here's a short example:
/*
** getip.c - a hostname lookup demo
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct hostent *h;
if (argc != 2)
{
// error check the command line
fprintf(stderr,"usage: getip address\n");
exit(1);
}
if ((h=gethostbyname(argv[1])) == NULL)
{
// get the host info
herror("gethostbyname");
exit(1);
}
printf("Host name : %s\n", h->h_name);
printf("IP Address : %s\n", inet_ntoa(*((struct in_addr
*)h->h_addr)));
return 0;
}
On Dec 16, 2004, at 4:18 PM, Ryan M Joseph wrote:
gethostbyname? I can not find that function in any of my headers.
Do you you know where it exists? It sounds like what I need
anyhow. thanks.
On Thursday, December 16, 2004, at 02:16 PM, Mike Cohen wrote:
The usual way is to call gethostbyname, which takes a host name
and returns am address (as part of the returned structure) that
you can pass to connect.
On Dec 16, 2004, at 3:45 PM, Ryan M Joseph wrote:
I unfortunately don't understand much about addresses besides
IPs and even then not much. The problem still remains I don't
know enough about the protocol to fill in the fields properly.
For example the IP 128.0.0.0, how can I describe THAT with the
sockaddr. Is there a reference location of this information or a
function that could convert an IP into a sockaddr (like OT
maybe)? My real issue I think is not knowing the low-level
interpretation of IPs. Thanks again.
sockaddr is a generic thingy, that allows a single set of
function to calls to work with different types of address
(ipv4, ipv6, other stuff).
Various protocols give different meaning to the bytes that
follow the sin_length and sin_family fields, for ipv4 stuff
this is defined by the sockaddr_in structure.
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden