How to refuse Connections ?

Discussion in 'C Programming' started by victor, Apr 2, 2007.

  1. victor

    victor Guest

    I want my code to accept only connections to the max of N.. if any
    client tries to connect to my code when already there are N
    connections, then it musst be refused... How do i do it?
    P.S::: I can accept the connection then close the socket.. But is
    there any other elegant way?
    victor, Apr 2, 2007
    #1
    1. Advertising

  2. victor

    Ian Collins Guest

    victor wrote:
    > I want my code to accept only connections to the max of N.. if any
    > client tries to connect to my code when already there are N
    > connections, then it musst be refused... How do i do it?
    > P.S::: I can accept the connection then close the socket.. But is
    > there any other elegant way?
    >

    You'd better ask this on a platform specific programming group, sockets
    and friends are off topic here.

    --
    Ian Collins.
    Ian Collins, Apr 2, 2007
    #2
    1. Advertising

  3. victor

    Bill Pursell Guest

    On Apr 2, 5:07 am, "victor" <> wrote:
    > I want my code to accept only connections to the max of N.. if any
    > client tries to connect to my code when already there are N
    > connections, then it musst be refused... How do i do it?
    > P.S::: I can accept the connection then close the socket.. But is
    > there any other elegant way?



    This is not a question about C. You would probably
    have better results posting to comp.programming or
    some other group.
    Bill Pursell, Apr 2, 2007
    #3
  4. victor

    Default User Guest

    victor wrote:

    > I want my code to accept only connections to the max of N.. if any
    > client tries to connect to my code when already there are N
    > connections, then it musst be refused... How do i do it?


    There are no networking capabilities in standard C. It's all platform
    dependent. You need to find a newsgroup dedicated to yours.

    If you're using UNIX, comp.unix.programmer would be the place.




    Brian
    Default User, Apr 2, 2007
    #4
  5. victor

    victor Guest

    On Apr 2, 9:07 am, "victor" <> wrote:
    > I want my code to accept only connections to the max of N.. if any
    > client tries to connect to my code when already there are N
    > connections, then it musst be refused... How do i do it?
    > P.S::: I can accept the connection then close the socket.. But is
    > there any other elegant way?


    Thanx.
    victor, Apr 2, 2007
    #5
  6. victor

    Tor Rustad Guest

    Re: How to refuse Connections ? [OT]

    victor wrote:
    > I want my code to accept only connections to the max of N.. if any
    > client tries to connect to my code when already there are N
    > connections, then it musst be refused... How do i do it?
    > P.S::: I can accept the connection then close the socket.. But is
    > there any other elegant way?


    After you call listen(), the socket enter the LISTEN state. When client
    connect, it send SYN, which enter a incomplete connection queue on
    server. Server replies with SYN+ACK, and socket enter the SYN_RCVD state.

    Unless client try a SYN flood attack, it will reply with ACK. When the
    ACK is received at server, the socket enter the ESTABLISHED state and is
    moved from the incomplete queue to the complete queue.

    Now, if accept() is called by the server, you remove it from the
    completed queue.

    Why would need another way to remove a connection from the completed queue?

    If you don't remove it, you will sooner or later trigger a SYN flood on
    your own! :)

    --
    Tor
    Tor Rustad, Apr 4, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wolf

    Why connet refuse??

    wolf, Feb 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    638
  2. Bisser Milanov

    Re: Debuger suddenly refuse to debug

    Bisser Milanov, Jun 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    396
    Ken Cox [Microsoft MVP]
    Jun 26, 2003
  3. Peter Row
    Replies:
    0
    Views:
    343
    Peter Row
    Mar 4, 2004
  4. Replies:
    6
    Views:
    433
  5. Barrett
    Replies:
    1
    Views:
    283
    Gabriel Genellina
    Apr 23, 2010
Loading...

Share This Page