5 years, 7 months ago.

TCPConnect function blocking or not

Hi,

I am working on a embeded device, which should be able to communicate using UDP as well as TCP. Cloud server is sending different types of commands to device (for setting, getting parametars of device etc.), and beside that device is sending some basic info data to server in predefined periods of time. I have so far done udp communication using UDPSocket api and set blocking to false (i am pooling connection in free run, setting signals - received, ready to send, sent... whole application is single - threaded) and everything works fine. I have some unclearences concerned with blocking and non blocking functions.

It is unclear to me how to use TCPSocket connect() and accept() functions, how set blocking affects the connect() function? If i set blocking to false and call connect function, will my main loop continue executing after connect request is sent, or blocks until whole connection handshake is done? Would it be better to use blocking sockets and do receive, send, connect in another thread? Do TCP and UDPSocket classes start some internal threads already?

Device is a real-time timing device, therefore i must take care that microcontroller never blocks and keep the time used for communicationg to minimum.

Thank you in advance for any advice, Nikola

Be the first to answer this question.