473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to refuse Connections ?

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?

Apr 2 '07 #1
5 2112
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.
Apr 2 '07 #2
On Apr 2, 5:07 am, "victor" <ramkumar2...@gmail.comwrote:
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.
Apr 2 '07 #3
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
Apr 2 '07 #4
On Apr 2, 9:07 am, "victor" <ramkumar2...@gmail.comwrote:
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.

Apr 2 '07 #5
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
Apr 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
4
by: Angelos | last post by:
I get this error mysql_pconnect Too many connections ... every now and then. Does anyone knows where it comes from ? There are a lot of sites running on the server and all of them use the...
1
by: C Sharp beginner | last post by:
I'm sorry about this verbose posting. This is a follow-up to my yesterday's posting. Thanks William for your reply. I understand it is a good practice to open connections as late as possible and...
12
by: zhimin | last post by:
With C#, I had created two threads in one program. One is a TCP listener, and the other is TcpClient. After the Listener thread started, the client thread started try to connect to the listener,...
8
by: Sam | last post by:
Hello I was wondering is it possible to refuse the creation of an object. For example if the user doesn’t enter a correct string (as a parameter in the constructor), could the object refuse to...
2
by: Bob | last post by:
We have a production web site that's data intensive (save user input to DB and query for displaying) with the ASP.NET app part on one W2K server and SQL 2000 DB on another W2K server. I have set...
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
4
by: elyob | last post by:
Not really tried going two ways at once, but I have an include_once connection to a mysql_database, now I need to retrieve info from a second mysql_database .. My mysql_connects are getting...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.