M
Mr. X
Hello all,
Please advise...
Consider the following...
void init_sockaddr (struct sockaddr_in *name, const char *hostname,int port)
{
struct hostent *hostinfo;
name->sin_family = AF_INET;
name->sin_port = htons (port);
hostinfo = gethostbyname (hostname);
#if ONEWAY
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
#endif
#if ANOTHERWAY
bcopy(hostinfo->h_addr, (char*)&(name->sin_addr), hostinfo->h_length);
#endif
}
As I understand, there will be problems with the first way.
Because once the CPU leaves the function, hostinfo might be lost.
For now, it works, but I imagine it might one day fail.
My bigger concern is why it even compiles?
What is the "*" to the left of the "(" in that line?
What is it doing?
Admittedly, it was a mistake that worked, but I am more interested
in
Please advise...
Consider the following...
void init_sockaddr (struct sockaddr_in *name, const char *hostname,int port)
{
struct hostent *hostinfo;
name->sin_family = AF_INET;
name->sin_port = htons (port);
hostinfo = gethostbyname (hostname);
#if ONEWAY
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
#endif
#if ANOTHERWAY
bcopy(hostinfo->h_addr, (char*)&(name->sin_addr), hostinfo->h_length);
#endif
}
As I understand, there will be problems with the first way.
Because once the CPU leaves the function, hostinfo might be lost.
For now, it works, but I imagine it might one day fail.
My bigger concern is why it even compiles?
What is the "*" to the left of the "(" in that line?
What is it doing?
Admittedly, it was a mistake that worked, but I am more interested
in