c - ntohl used on sin_port and get negative nubmers -


i try print client port in server application in c. negative numbers of client port, strange behaviour:-/ 1 have idea problem?
part of code cause problem:

struct sockaddr_in client_address; int chosenport = (int) ntohl(client_address.sin_port); pritf("client port %d, chosenport"); 

i port -2121400320.

use ntohs() instead - sin_port 16-bit value.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -