Rejecting a connection
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Rejecting a connection




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Rejecting a connection  
aamesster@googlemail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-30-06 06:15 PM

Hi all,

I've been wondering how to reject a connection? Instead of accept() I
would like to "decline()" a connection. The only way of rejecting
connections I've thought about is to accept() and then close()
immediatelly. But would the other end actually receive the accept and
then the connection would be dropped?

Regards,
David






[ Post a follow-up to this message ]



    Re: Rejecting a connection  
Eric Sosman


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-30-06 06:15 PM



aamesster@googlemail.com wrote On 05/30/06 10:58,:
> Hi all,
>
> I've been wondering how to reject a connection? Instead of accept() I
> would like to "decline()" a connection. The only way of rejecting
> connections I've thought about is to accept() and then close()
> immediatelly. But would the other end actually receive the accept and
> then the connection would be dropped?

The other end never "receives the accept" because even
in normal operation, accept() doesn't transmit anything.
The socket returned by accept() has already completed its
three-way handshake and is in the connected state; the fact
that accept() returns is just bookkeeping on the listening
side and does not affect the connection at all.

When you close the connection, the other end's TCP/IP
stack will learn about it fairly promptly in the course
of events for a normal shutdown.  The application on the
other end probably won't learn about the disconnect until
it tries to send or receive something.

As for "rejecting" connections -- well, the simplest
way is never to listen() in the first place.  But assuming
that you want to permit some connections while forbidding
others, it follows that you must listen() and accept().
After accept() returns you can make your decision and either
communicate or close.

--
Eric.Sosman@sun.com






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:57 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register