It appears you are specifying the host/port you just bound as the tcp server, as the source host/port for the outgoing tcp connection attempt. That won't work, as you can see from the error you got. You would need to change the source port you want to use, or specify nil for the second param to let the kernel pick an appropriate source host/port.
Was there some particular reason you wanted to specify the host/port for the outbound conn?
> if err != nil {
> panic(err)
> }
>
> fmt.Println("IT WORKS!")
> }
>
> The DialTCP() call fails with "address already in use".
>
> Is there a way to set SO_REUSEADDR using Go? More generally, is there any
> way in go to achieve what I want?
>
> Thanks.
>
> -Bruno
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>