Reputation: 451
This part week I have been learning about unix sockets and I have a dount regarding connect() call from the client application.
Is the connect() function call BLOCKING. Will it BLOCK till the server application creates its own socket, binds it to the same address and start listening for incoming connections?
In my client, what I have is
printf(" abc %s\n", bind_path);
if((retval = connect(sh->sock_fd, (const struct sockaddr*)&sadr, sizeof(struct sockaddr_un))) == -1)
{
perror("123");
return SOCKET_ERROR;
}
return SOCKET_OK;
And what I get is,
ankit@ankit-ThinkPad-W530:~/Desktop/week2_3_tasks/ipc_socket_exercise$ ./user_application_proc2_client.out
**** Process 2 (Client) Started
**** Process 2 PID : 7106
/tmp/sock_10
**** Socket connected successfully with handle 3
abc /tmp/sock_10
123: No such file or directory
**** Error connnecting socket to address .. exiting
Upvotes: 0
Views: 1263
Reputation: 58929
Is the connect() function call BLOCKING[?]
Not for UNIX sockets. It may block for other kinds of sockets (such as IP sockets).
Will it BLOCK till the server application creates its own socket, binds it to the same address and start listening for incoming connections?
No. You saw this yourself - you got a "no such file or directory" error! Clearly it didn't wait for a server before it returned that error.
Upvotes: 2