why there is still bind error:address already in use

  • Follow


i write a program with socket.
and i have used the function setsockopt(listenfd , SOL_SOCKET , SO_REUSEADDR
, &opt , sizeof(opt)),
but there is still an error "bind error:address already in use"
why?


0
Reply zhengda 4/21/2004 2:52:39 PM

In article <c661sj$3uj$2@mail.cn99.com>,
 "zhengda" <zhengda1936@sina.com> wrote:

> i write a program with socket.
> and i have used the function setsockopt(listenfd , SOL_SOCKET , SO_REUSEADDR
> , &opt , sizeof(opt)),
> but there is still an error "bind error:address already in use"
> why?

Show us some more code.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
0
Reply Barry 4/21/2004 3:13:27 PM


"zhengda" <zhengda1936@sina.com> wrote in message 
news:c661sj$3uj$2@mail.cn99.com...

>i write a program with socket.
> and i have used the function setsockopt(listenfd , SOL_SOCKET , 
> SO_REUSEADDR
> , &opt , sizeof(opt)),
> but there is still an error "bind error:address already in use"
> why?

    Because the address is in use?

    DS


0
Reply David 4/21/2004 3:57:35 PM

"zhengda" <zhengda1936@sina.com> writes:

> i write a program with socket.  and i have used the function
> setsockopt(listenfd , SOL_SOCKET , SO_REUSEADDR , &opt ,
> sizeof(opt)), but there is still an error "bind error:address
> already in use" why?

Use netstat to see if the port is already bound by something else.

Joe
-- 
If people don't want to come out to the ballpark, nobody's going
to stop them.
  - Yogi Berra
0
Reply joe 4/21/2004 5:32:25 PM

"zhengda" <zhengda1936@sina.com> wrote in message news:<c661sj$3uj$2@mail.cn99.com>...
> i write a program with socket.
> and i have used the function setsockopt(listenfd , SOL_SOCKET , SO_REUSEADDR
> , &opt , sizeof(opt)),


have you set the var 'opt' to the correct (positive) value?
Calling setsockopt() with opt = 0 is not effective.

-John
0
Reply johngalt__ 4/23/2004 8:54:58 PM

4 Replies
653 Views

(page loaded in 0.739 seconds)

Similiar Articles:













7/23/2012 4:49:59 AM


Reply: