473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to bind a range of local port for client socket


I need to specify a range of outgoing port numbers (i.e., 20000-21000). Is
there any way to bind this range so that when system picks up a free port, it
will only pick one from this range? I know I can bind a specific port number
but I'd rather let the system pick up an available one from the specific
range.

Can someone tell me how to do that?

Thanks in advance,

Nov 17 '05 #1
3 3616
Franky,

You should have to take a look at this :
http://www.planet-source-code.com/vb...odeId=904&lngW
Id=10
Best Regards
Vuong,
Tran Xuan

"Franky" <Fr****@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...

I need to specify a range of outgoing port numbers (i.e., 20000-21000). Is
there any way to bind this range so that when system picks up a free port, it will only pick one from this range? I know I can bind a specific port number but I'd rather let the system pick up an available one from the specific
range.

Can someone tell me how to do that?

Thanks in advance,

Nov 17 '05 #2
Vuong,

Thanks, but the linked one is not using any port binding. It was just a
simple port scanning.

"Vuong" wrote:
Franky,

You should have to take a look at this :
http://www.planet-source-code.com/vb...odeId=904&lngW
Id=10
Best Regards
Vuong,
Tran Xuan

"Franky" <Fr****@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...

I need to specify a range of outgoing port numbers (i.e., 20000-21000). Is
there any way to bind this range so that when system picks up a free port,

it
will only pick one from this range? I know I can bind a specific port

number
but I'd rather let the system pick up an available one from the specific
range.

Can someone tell me how to do that?

Thanks in advance,


Nov 17 '05 #3
Franky,
If you can scan available ports from range, you can bind at these ports.
And obviously, you can choose the port is available for use

Best Regards,
Vuong
Tran Xuan

"Franky" <Fr****@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
Vuong,

Thanks, but the linked one is not using any port binding. It was just a
simple port scanning.

"Vuong" wrote:
Franky,

You should have to take a look at this :
http://www.planet-source-code.com/vb...odeId=904&lngW Id=10
Best Regards
Vuong,
Tran Xuan

"Franky" <Fr****@discussions.microsoft.com> wrote in message
news:BE**********************************@microsof t.com...

I need to specify a range of outgoing port numbers (i.e., 20000-21000). Is there any way to bind this range so that when system picks up a free port,
it
will only pick one from this range? I know I can bind a specific port

number
but I'd rather let the system pick up an available one from the

specific range.

Can someone tell me how to do that?

Thanks in advance,


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Johannes Eble | last post by:
Hello Python community, I am trying the echo-client and echo-server examples in Chapter 10, "Programming Python" by Mark Lutz. It is probably the most simple sockets sample: A socket server just...
2
by: sashan | last post by:
I'm writing a program using sockets. I'm binding to a port like this: PORT = 5000 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST,...
7
by: USUN_TO | last post by:
Hi, i got problem when i bind in this way: local_addr.sin_family = AF_INET; local_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); local_addr.sin_port = htons(CLIENT_PORT); i can easly bind...
1
by: HABJAN ®iga | last post by:
Hello, how can i bind a socket for listen on some port, and all addresses : In the sample i bind myself to localhost(127.0.0.1) on port 5500. It works fine when connecting to localhost, but if...
1
by: gregory_may | last post by:
I want to bind multiple UDPClients to the same port on the same machine. I want them to all listen for broadcast messages & respond accordingly. Multiple client bindings "under normal...
14
by: DaTurk | last post by:
I am makeing a Multicast server client setup and was wondering what the difference is between Socket.Connect, and Socket.Bind. It may be a stupid question, but I was just curious. Because I...
5
by: natambu | last post by:
I have a linux box with multiple ip addresses. I want to make my python client connect from one of the ip addresses. Here is my code, no matter what valid information I put in the bind it always...
1
by: MaheBytes | last post by:
I have been facing a problem with UDP socket programming. I have to reuse port number for two different IP address. I am actually using SO_REUSEADD. I have no problem with debug version but with...
6
darksteel21
by: darksteel21 | last post by:
Hi to all, I am currently developing an application in perl that is capable of connecting to a server and sends information.. the server has a deamon that listens to the socket connections. It...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.