Hello
Thanks Quinn for taking the time to answer but to be honest I don't understand the answer... I'm talking about binding a socket in order to listen on it.
A little snippet of code is better than a long speech, here is what I'm trying to do:
int main(int argc, const char * argv[]) {
struct sockaddr_in addr;
int sock, res;
addr.sin_port = htons(80);
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr("192.168.1.30"); // Works with htonl(INADDR_ANY)
sock = socket (AF_INET, SOCK_STREAM, 0);
res = bind (sock, (struct sockaddr *)&addr, sizeof(addr));
if (res < 0)
perror ( "bind" );
res = listen (sock, 1);
if (res < 0)
perror ( "listen" );
res = close (sock);
if (res < 0)
perror ( "close" );
return 0;
}
Binding on lower ports always returns error 13 Permission Denied with any other value than ANY_ADDR.
Shouldn't we use our helpertool or is there a way to do without it?
Yannick TRINH @ 4D SAS
Topic:
App & System Services
SubTopic:
Core OS
Tags: