>>>>> On Wed, 19 Mar 2003 19:45:39 +0200
VN>
>>>> 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() ?
j> You're mixing apples and oranges. A listening socket can't be used for
j> anything but accepting connections. It's not connected to anything.
AK> You are wrong. Look at TCP state diagram. Simultaneous open is allowed
AK> in TCP, and Stevens writes about it in UNPv1 TCP Connection
AK> Establishment and Termination
VN>
VN> I think you mixed *sockets* and *ports*. BSD sockets don't allow socket
VN> to switch to listening state after connect(), and don't allow to do
VN> connect on socket which is listening. This has no common with TCP states,
VN> TCP ports (as numbers in per-host addressing space), TCP by itself, and
VN> simultaneous opening of a port using different sockets (which may require
VN> SO_REUSEADDR and SO_REUSEPORT).
Oops, I was wrong, but in another way. I remembered that there is a
branch from LISTEN to SYN_SEND in TCP state diagram (and from SYN_SENT
we can achieve simultaneous open), but I had not remembered that it is
used not on OPEN, but on SEND, so this really can not occur with BSD
sockets.
Sorry for misinformation,
--
Alexander Kotelnikov
Saint-Petersburg, Russia