RIscRIpt
RIscRIpt

Reputation: 163

Windows sockets htons(80) vs 0x5000

When I am writing port to SOCKADDR_IN structure, can I use 0x5000 instead of htons(80)?

(Why 0x5000? -- I debugged htons(80) and it returned 0x5000)

Upvotes: 0

Views: 924

Answers (2)

user207421
user207421

Reputation: 310980

You can, but why would you want to? What's the problem with being portable? and clear? and the same as everyone else who has ever written this code?

Upvotes: 0

SomeWittyUsername
SomeWittyUsername

Reputation: 18368

You can but it won't be portable. htons exists for you not to worry about byte ordering in your computer and network (and they can be different on various systems).

Upvotes: 2

Related Questions