server address and port - Unix
This is a discussion on server address and port - Unix ; testing my web server under BSD i have used
my_addr.sin_family = AF_INET; /* IPv4 address */
my_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* all addresses */
my_addr.sin_port = htons(SRV_PORT); /* SRV_PORT, network order */
to set the address of webserver and its port.
...
-
server address and port
testing my web server under BSD i have used
my_addr.sin_family = AF_INET; /* IPv4 address */
my_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* all addresses */
my_addr.sin_port = htons(SRV_PORT); /* SRV_PORT, network order */
to set the address of webserver and its port.
now i would initialize the address and the port number in the prompt
command of my webserver
like
./webserver 127.0.0.1 8080.
i receive these parameter from the main but when i try to use them
into my_addr and i try to bind the bind function returns an error.how
i can do that?
thanks
-
Re: server address and port
In article
,
Mr_John wrote:
> testing my web server under BSD i have used
> my_addr.sin_family = AF_INET; /* IPv4 address */
> my_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* all addresses */
> my_addr.sin_port = htons(SRV_PORT); /* SRV_PORT, network order */
> to set the address of webserver and its port.
> now i would initialize the address and the port number in the prompt
> command of my webserver
> like
> ./webserver 127.0.0.1 8080.
> i receive these parameter from the main but when i try to use them
> into my_addr and i try to bind the bind function returns an error.how
> i can do that?
> thanks
Can you show your code? Are you using inet_addr() to convert
"127.0.0.1" into an address?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
-
Re: server address and port
> Can you show your code? *Are you using inet_addr() to convert
> "127.0.0.1" into an address?
>
i was using
serv_add.sin_addr.s_addr = htonl(atoi(argv[1]);
now i've tried inet_addr() and it works.but i have another question to
give u: i see that i can use just the 127.0.0.1 address if i use
another address it can't bind.can u tell me why?
thanks
-
Re: server address and port
>> Can you show your code? *Are you using inet_addr() to convert
>> "127.0.0.1" into an address?
>>
>i was using
>serv_add.sin_addr.s_addr = htonl(atoi(argv[1]);
>now i've tried inet_addr() and it works.but i have another question to
>give u: i see that i can use just the 127.0.0.1 address if i use
>another address it can't bind.can u tell me why?
You can only bind to an IP address of an interface on your system,
as distinguished from just making one up.
-
Re: server address and port
thanks a lot i got now.thanks