1

Topic: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Greetings! I am connected to some server which "does not listen" at present to port, and I receive connection timed out later 5 minutes. Baffles that it is necessary to wait already five minutes. In Google there are decisions on socket transfer in a non-blocking mode, but for this purpose it is necessary to have  a socket descriptor. But boost:: asio:: ip:: tcp:: socket receives  a descriptor only after a connection. I.e. this code will not work until will be connected: boost:: asio:: ip:: tcp:: socket socket (io_service); boost::asio::socket_base::non_blocking_io command (true); socket.io_control (command); there is still a variant to create a socket descriptor with the help int s =:: socket (...); and to transfer it in , but it is somehow ugly... There are ideas? Thanks.

2

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> there are ideas? A deadline the timer on socket closing, not? X> thanks. Please.

3

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, antropolog, you wrote: A> a deadline the timer on socket closing, not? Well  absolutely extreme variant...

4

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> I am connected to some server which "does not listen" at present to port, and I receive connection timed out later 5 minutes. A delightful example for a recent subject "Pougaraem over With ++". That there are in pure socket api decades, misses till now in wonderful libraries with type name spaces "boost:: asio:: ip:: tcp:: socket". At once it is visible, forever did. And suddenly there will be not ip? And suddenly there will be not tcp? And for us for this purpose  is available, we clever, we provided! On the question - here create a socket separately and transfer its descriptor. Wrap it in beautiful OOP-wrapper.  I ask to explain your position.

5

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, Glory, you wrote: generally in asio it is possible to receive at any moment  a socket and to work with it directly, simply author at all does not understand that does, and does not understand that it is absolutely not necessary for it, does strange (wants to translate a socket in a non-blocking mode, aha. The library title asio to it is visible about what does not speak) and consequently asks the strange. I gave the right answer to it, but probably should transit years before it it realizes. p.s. And still  with the thin sincere organization and the patient ))

6

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, antropolog, you wrote: A>... Simply author at all does not understand that does ridiculous, however) take a descriptor from not connected socket and work with it, about the understanding...

7

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> take a descriptor from not connected socket and work with it, about the understanding... Give you you will begin that you will tell, what for you want to translate a socket in a non-blocking mode.

8

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, antropolog, you wrote: A> give you you will begin that you will tell, what for you want to translate a socket in a non-blocking mode. It is necessary to begin with you. Show, how you use a dead socket (i.e.-1) and what profit from it?

9

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> it is necessary to begin with you. All is clear. Google further with such tone.

10

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, antropolog, you wrote: X>> take a descriptor from not connected socket and work with it, about the understanding... A> give you you will begin with that A> give you you will begin with that A> give you you will begin with that I understand that it is a malicious offtopic, but it seems to me that in arguing desperately there is phrase "an orthodox censer" no Tajmaut by default normally makes about 72 seconds, these are 5 sendings SYN with an increasing interval of waiting of answer SYN, ASK. Whence at  5 minutes undertook? Explicitly something not the system.

11

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> I am connected to some server which "does not listen" at present to port, and I receive connection timed out later 5 minutes. X> baffles that it is necessary to wait already five minutes. So and  you as? Through async_connect or through connect? If through async_connect what difference after what time you receive an error?

12

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> in Google there are decisions on socket transfer in a non-blocking mode, but for this purpose it is necessary to have  a socket descriptor. But boost:: asio:: ip:: tcp:: socket receives  a descriptor only after a connection. X> there are ideas? Is: to read hardly further to dock about open (). #include <boost/asio.hpp> #include <stdio.h> int main () {boost:: asio:: io_service io_service; boost:: asio:: ip:: tcp:: socket s1 {io_service}; boost:: asio:: ip:: tcp:: endpoint endpoint {}; s1.open (endpoint.protocol(); s1.non_blocking (true); printf ("%d\n", (int) s1.native_handle ());} Produces: 6. strace confirms: 16551 18:11:05.785966 socket (PF_INET, SOCK_STREAM, IPPROTO_TCP) = 6 16551 18:11:05.786018 epoll_ctl (4, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=17247824, u64=17247824}}) = 0 16551 18:11:05.786066 ioctl (6, FIONBIO, [1]) = 0 16551 18:11:05.786173 fstat (1, {st_mode=S_IFCHR|0620, st_rdev=makedev (136, 24)...}) = 0 16551 18:11:05.786228 write (1, "6\n", 2) = 2

13

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, so5team, you wrote: S> If through async_connect what difference after what time you receive an error? async_connect (). The matter is that if so long time is is specific this service (microservice architecture) cannot define the state - there is a situation with non-uniform equalization of loading of others, depending from it (these. Them a little.) services. I will repeat - the error quite suits me for it is logical. Does not arrange time of obtaining of this error.

14

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, netch80, you wrote: N> Is: to read hardly further to dock about open (). Yes, about open () I did not think... And generally never it used. I will check up on Monday, I will unsubscribe.

15

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: S>> If through async_connect what difference after what time you receive an error? X> async_connect (). X> I will repeat - the error quite suits me for it is logical. Does not arrange time of obtaining of this error. Then it is not clear, in what your problem: you do async_connect, have possibility to continue operation while operation connect is fulfilled asynchronously so what for you need still something non-blocking from a socket - not clearly. It is necessary to reduce time? Well so already advised to expose a time-out for time which suits you.

16

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, so5team, you wrote: S> Then it is not clear, in what your problem: you do async_connect, have possibility to continue operation while operation connect is fulfilled asynchronously... Described above. This type of service cannot fulfill any operation will not be connected yet to other service. And as it so long time is in an indefinite state -  (for services of this type) cannot make decision to change load distribution, because from its side with  all apprx. possible here and an architectural error for  knows nothing about that at  there can be a connection state,  so long... A variant with the timer - the most obvious. But I wanted to smoke towards system API, ...

17

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> there are ideas?  I recommend to use timers  dock including: http://www.boost.org/doc/libs/1_65_1/do … client.cpp

18

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> I am connected to some server which "does not listen" at present to port, and I receive connection timed out later 5 minutes. Before connection check up availability of port. To google icmp and raw sockets.

19

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, Glory, you wrote: the Delightful example for a recent subject "Pougaraem over With ++". That there are in pure socket api decades, misses till now in wonderful libraries with type name spaces "boost:: asio:: ip:: tcp:: socket" You inside that glance.

20

Re: asio, tcp socket, async_connect () and ' connection timed out ' later 5 minutes

Hello, niXman, you wrote: X> greetings! X> I am connected to some server which "does not listen" at present to port, and I receive connection timed out later 5 minutes. X> baffles that it is necessary to wait already five minutes. I couple of days ago suffered the same, but synchronously, but in this case if the server does not listen, I receive an exception/error almost at once. If in your case such problem only at an asynchronous connection, it is possible to make first of all the synchronous connection as check of availability of a node, to be disconnected and be connected already as it is necessary. Reminds a rusty railway crutch, but can work