How to refuse Connections ?

V

victor

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?
 
I

Ian Collins

victor said:
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.
 
B

Bill Pursell

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.
 
D

Default User

victor said:
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
 
V

victor

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.
 
T

Tor Rustad

victor said:
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! :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top