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);

Reply via email to