Archived Forum Post

Index of archived forum posts

Question:

iOS Socket's Connect (c++ api) method always return true on iOS

Mar 18 '13 at 12:30

We use iOS chilkat socket library for iOS project. We use c++ api for our needs. We have an issue with "Connect" (without ssl) method. It always return true. Even if server is not running. (BTW on windows project it works as expected.) When we try to read something from this socket (on iOS side) with the usage of method "ReceiveBytesN" it returns false. get_IsConnected() function returns false and last error is:

ChilkatLog:
  IsConnected:
    DllDate: Sep 19 2012
    UnlockPrefix: **
    Username: ***
    Architecture: Little Endian; 32-bit
    Language: IOS Objective-C
    VerboseLogging: 0
    fd: 0x6
    objectId: 1
  --IsConnected
--ChilkatLog
Did anyone have such problem?


Answer

I used the lates version of library (9.4.0). Result is the same. I'll try to use VerboseLogging and and LastErrorText after connect. Then I'll give an update here.


Answer

Computer with destination IP is powered off.

Here is updated log from LastErrorText after calling function Connect:

ChilkatLog:
  Connect_Socket:
    DllDate: Dec 21 2012
    UnlockPrefix: *
    Username: *
    Architecture: Little Endian; 32-bit
    Language: IOS Objective-C
    VerboseLogging: 1
    objectId: 1
    hostname: *
    port: *
    ssl: 0
    maxWaitMs: 20000
    ConnectTimeoutMs_1: 20000
    calling ConnectSocket2
    IPV6 enabled connect with NO heartbeat.
    This is an IPV4 numeric address...
    AddrInfoList:
      AddrInfo:
        ai_flags: 0
        ai_family: 2
        ai_socktype: 1
        ai_protocol: 6
        ai_addrlen: 16
        ai_canonname: (NULL)
      --AddrInfo
    --AddrInfoList
    Connect using IPV4.
    ipAddress1: *
    Info: Socket operation in progress..
    myIP_3: *
    myPort_3: *
    connect successful (2)
    socketOptions:
      SO_SNDBUF: 131072
      SO_RCVBUF: 131072
      TCP_NODELAY: 0
    --socketOptions
    Success.
  --Connect_Socket
--ChilkatLog

Answer

Any updates?


Answer

The information in the LastErrorText shows that the connect system call succeeded. (see http://linux.die.net/man/2/connect ) I don't have any other answer.


Answer

Found out some new information. When computer, where Server is installed, is off socket's function "connect" works as expected. (after timeout returns false)