This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Can the function "connect()" & "listen() + accept()" be used with the same TCP port at the same time ?
- From: "Louie Chan" <louie at unitednet dot com dot hk>
- To: "LLeweLLyn Reese" <llewelly at lifesupport dot shutdown dot com>, "lixd" <lixdfromjx at yeah dot net>
- Cc: <gcc-help at gcc dot gnu dot org>, <lixdfromjx at yeah dot net>
- Date: Sun, 16 Mar 2003 03:47:34 +0800
- Subject: Can the function "connect()" & "listen() + accept()" be used with the same TCP port at the same time ?
Dear sir/madam,
Does anyone know if I can use the functions "listen() & accept()" after one successful TCP connection with the function "connect" ?
Please refer to the following concept codes !!
int sockfd, new_connect_fd;
sockfd = socket(domain, type, protocol);
connect(sockfd, sockaddr, addrlen); <--- connect() and connection successful !
listen(sockfd, backlog);
new_connect_fd = accept(sockfd, sockaddr, addrlen); <--- Can the accept() be used after using connect() ?
Thanks for your help !
Best Regards. Louie