I have tried to connect tcp server through 4g mobile hotspot and found a problem. When I tried to connect to non-existed server, the connect function still returns zero and a few seconds later, it has closed. It look like asynchronous connection. Anyone experiencing this issue? Any help comment appreciated. Thanks.
Asked
Active
Viewed 504 times
-3
-
1Please show the code where you create the socket, and perform the "connect()". Also show any "fcntl()" calls you have made on the socket descriptor. – TonyB Apr 18 '16 at 04:56
-
Sounds like maybe your 4g provider is using some kind of proxy? In any case, you'll probably just need to handle the behavior the same as you would any other TCP disconnect initiated by the server. – Jeremy Friesner Apr 18 '16 at 05:28
-
Thanks for the response. The code is working fine in normal way and this is not related with my code. only raised when I connect through hotspot(iPhone). @tonyb – Chen Apr 18 '16 at 07:18
-
"*and this is not related with my code.*" it definitely is. As with exactly this code you are observing this behaviour. – alk Apr 18 '16 at 08:53
-
How do you connect, using which kind of socket? – alk Apr 18 '16 at 08:54
-
I have tried both of Linux and Windows socket. And blocking mode. In a word, the problem is connect function return zero even no server running when try through hotspot. All working fine through normal router. @Jeremy understands the issue correctly. – Chen Apr 18 '16 at 09:36
1 Answers
0
It is probably due to the way how the mobile hotspot implements NAT (Network Address Translation). NAT is implemented by making two connections (inbound and outbound) and relaying data between the two. It is possible for your mobile hotspot to accept your connection first and then try to make the outbound connection. NAT operation is typically transparent, but it's implementation dependent.

jaeheung
- 1,208
- 6
- 7