|
Dlin |
at May 14, 2013 at 9:29 am
|
⇧ |
| |
Thank you,
In fact,
In my test, not only the web server required a free port.
I required multiple clients assigned by local port number.
Is there API to get the free local port number for the clients to use?
At the first test, the test will pass.
At 2nd test, the client dialer Dial() to server will caused 'address
already used' error.
And use 'netstat -tan | grep <port>' will see it is on TIME_WAIT state.
So, I think to let the auto test smooth is to get a free local port at
first.
On Tuesday, May 14, 2013 5:12:22 PM UTC+8, Jim Teeuwen wrote:Use Port 0. The operating system will then assign you a free one
automatically.
You can see which one was chosen through Listener.Address(), after it has
opened.
On Tuesday, May 14, 2013 9:53:44 AM UTC+2, dlin wrote:
I want to write a test program to test web server which register a free
port.
But, when we Listening, we must provide a parameter e.g :6060.
Because port 6060 is occupied by godoc sometimes, I wish my
server_test.go will run as soon as possible.
So, I require to assign a free port number.
Any suggestion?
--
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+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.