The server port comes from a URL, e.g. http://10.44.10.1:80, and I just atoi the port. I have checked with a network trace that the correct port is being connected to. With previous versions of Traffic Server I never had to use ntohs and just passed in the atoied number.
On 12 September 2011 15:57, Alan M. Carroll <a...@network-geographics.com>wrote: > Actually, Chris, you should use htons since this is going from host to > network order. However on all modern systems htons() and ntohs() are the > same function. Some of us old timers remember systems where that wasn't the > case but those have long since faded to memories. > > I think TSNetConnect gets tested during regression, so this seems a rather > unexpected failure. From where do you get server_port? atoi and its ilk, > hard wired constant, or some other network connection? > > Can you do a netstat -a -n --tcp and verify that the listening process is > listening on the port you expect? > > Monday, September 12, 2011, 9:20:26 AM, you wrote: > > > On 3.1 I have to use the ntohs function for the port number when using > > TsNetConnect. Have you tried this? > > > On 12 September 2011 02:33, steven liu <stevenli...@gmail.com> wrote: > > >> Thanks. Yes. I am setting port using hons() using following codes. > > >> struct sockaddr_in ip4addr; > >> ip4addr.sin_family = AF_INET; > >> ip4addr.sin_port = htons(server_port); > >> ip4addr.sin_addr.s_addr = inet_addr((const char *)("127.0.0.1")); > >> action = TSNetConnect(contp, (struct sockaddr const*)&ip4addr); > >