What problems I'll get if I will fix the network port my application is listening?

1

I observe this behviour from very famous projects. For example apache and nginx, they both by default trying to listen port 80 and if it's already occupied then they just fail to start and need to be reconfigured.

What if for my small server project I pick some port not mentioned on List of port numbers yet? My goal is to make the server application working at most of households with wi-fi routers. They usually don't have any unusual ports occupied (or they do?). So if I occupy the one I shouldn't have problems most of the time. Am I wrong? What problems I might get with this approach?

vladimir

Posted 2013-08-07T19:42:21.173

Reputation: 277

Question was closed 2013-08-09T12:50:03.130

See this: http://superuser.com/questions/381058/what-is-the-purpose-of-ports?rq=1

– Ƭᴇcʜιᴇ007 – 2013-08-07T19:45:09.927

@vladimir why don't you design your application to have a fallback solution? (ie try other ports if one is taken). – tay10r – 2013-08-07T21:55:16.177

Yeah. That's what I'm choosing between - fixed port or selecting available port. For the port I need to drill a hole in router through UPnP. So I'm not sure how that gonna work if the port will change every server restart. It's obviously more work for me but might work better. – vladimir – 2013-08-08T01:15:05.137

Answers

0

Yes, you just pick a port and hope nothing else is using it. That's the way it goes. :)

May I suggest you attempt to make the port configurable by the user? That way if they do have a port conflict, it can be changed to resolve the conflict.

More info over at StackOverflow:

Ƭᴇcʜιᴇ007

Posted 2013-08-07T19:42:21.173

Reputation: 103 763

Unfortunatly I can't rely on users at all. I have to assume that user doesn't have a clue and shouldn't be selecting ports. I'm more deciding should I put some logic (executed at first run) which determines available port or I really just can hardcode it at some configuration file and keep fingers crossed. Thanks for the recommended reading - I should do my homework first! – vladimir – 2013-08-07T19:56:59.090

Make NO assumptions. There's plenty of users who knowingly setup custom ports for their own uses; less and less users are the technical neophytes of yester-year. ;) – Ƭᴇcʜιᴇ007 – 2013-08-07T20:22:57.857

Can't agree here. I observe the opposite. Sorry. I'm working on some small server which just should working right after plugging into network. No setup is a requirement. And I understand why - most of my non-IT friends have no clue about addresses and ports. Consumers age, what I can say... – vladimir – 2013-08-08T01:09:42.677