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
Post a Comment