Good day! I did not get an answer to my previous question . I will try again. The select function is called in a loop. And on different operating systems (particularly in Win7), it can randomly cause an exception. By trial and error, a crutch was coined as a call to Sleep (1) before calling select (). In this case, the program works stably. But the crutch is not an option and I would like to understand why this is happening. Perhaps you need to set some parameters for the socket?

Another small clarification about what the program does. In essence, this is an ssh-tunnel to the remote service. In this particular case, when the program crashes with a crit, I run mstsc (RDP client). The error may always pops up after authorization already on the rdp server, but not always immediately, sometimes the desktop may have time to load.

I would be grateful for any information that will help at least come close to the clue =)

Thank!

  • What type of sockets do you use? TCP and AF_NET? - nick_n_a
  • As for Sleep, I have such guesses: Windows is a multitasking system, the socket library creates one more thread for working with sockets. The sleep function gives a signal to switch to another thread, in which the socket library has time to do its actions (in the flesh until it calls an API that causes switching to another thread, one of which is Sleep, or until the multitasking system considers it necessary to switch in another thread). - nick_n_a
  • I think, because you have questions with select, try to look at already ready libraries, in particular, ftp protocol uses two sockets, client and server. See the implementation of ftpd.c (how select is used), for example, opensource.apple.com/source/network_cmds/network_cmds-77/… here - nick_n_a
  • Perhaps for select you need to create thread, and you work in single-thread. - nick_n_a
  • By and large, I don’t need the second thread, since The program only works for a single client. But actually, I really use the second thread. The first works a socket and the second monitors the running program and waits for it to complete, in order to terminate the socket. I think this is not the point. I do not see the connection, and this glitch manifested itself even before I added the second stream. - Markelov Edward

0