Hello people,
 here I was writing some code to initiate connection in endless loop, and
got stuck abit.. I would be greateful, if you could clarify some things. 
so I had in my code:

sockfd=socket(..);
while(1)
{
connect();
write();
read() with select() till remote closes connection(read returns eof);
}

but I feel like I will have to disconnect socket first, b/c I get "socket
is already connected otherwise".
I wonder how should this be done?
all what comes in mind is:


while(1)
{
sockfd=socket(..);
connect();
write();
read() with select() till remote closes connection(got eof);
close(sockfd);
}

but isn't it an overkill?

also, does connect modify sockaddr_in structure (so I would have to renew
it every time) or it's save enough to do it once. (so far I haven't noted
connect does any mess with it, but... )

 Thanks beforehands
 
Best regards
 Fyodor

Reply via email to