This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]