I researched and found that signal interruption can happen when programming with sockets. I have searched and found that in case of signal interruption, we should retry. That is, I have to catch the error and retry. I have to create socket like this.
int create_sock()
{
int sock;
while (1)
{
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1)
{
if (errno == EINTR)
{
continue;
}
else
{
perror("create_sock");
exit(-1);
}
}
break;
}
return sock;
}
Should I follow the above procedure in case of close, send and connect function?