Accept (sockets) queuing up connection requests


 
Thread Tools Search this Thread
Top Forums Programming Accept (sockets) queuing up connection requests
# 1  
Old 03-31-2011
Accept (sockets) queuing up connection requests

Yes, I guess that is what it is sort of meant to do but it is sort of a problem.

Scenario:
Server is running and is blocked at ACCEPT
Client A connects with server
Server returns from ACCEPT and moves to RECV call waiting for incoming string
Client B connects with server
Client B sends string
Client B closes
Client A sends string
Client A closes
Server prints Client A string
Server closes connection to Client A
Server loops back to ACCEPT (still keeps the same bind and listen)
Server immediately sees Client B connection request
Server returns from ACCEPT and moves to RECV
Server immediately sees string and prints it.
Server prints Client B string

So the problem is that the client has come and gone before the server has even started working for it. Is there any way the client connection can be refused if the server isn't ready to accept it yet? I guess removing the accept queue or setting it to zero or something?

Thanks,
Kevin

Last edited by Kam5FCC; 03-31-2011 at 11:44 AM.. Reason: Formating issues
# 2  
Old 03-31-2011
I'm not understanding the problem. The server doesn't have to accept() until it wants to, and clients will have to wait for the server to accept() before they can send anything (or until TCP timeout). If your clients don't always bother to wait for a reply, that would be their problem.
# 3  
Old 03-31-2011
Hi Corona,
Thanks for the reply.

What you are saying is correct if I was setting up a protocol and ack'ing all over the place. But what the boss wanted was a client that dumped off the data and left. Sooo....

But I think I may have just stumbled on to the answer myself.
listen(socket, QUE_LEN);
I'm thinking by setting my queue length to 1 the incoming connect requests will get refused. So off to try that.

Thanks much,
Kevin
# 4  
Old 03-31-2011
Quote:
Originally Posted by Kam5FCC
Hi Corona,
Thanks for the reply.

What you are saying is correct if I was setting up a protocol and ack'ing all over the place. But what the boss wanted was a client that dumped off the data and left. Sooo....
TCP doesn't do that. The connecting process itself makes you wait.

Making your queue small will just prevent most of your clients from connecting at all when the server's busy, imagine russian roulette with 5/6 cylinders full.

Two ways to solve this.

1) Create threads to handle connections. The main program just does accept(); create_thread(); accept(); create_thread(); The threads do the communication. The clients won't have to wait for client1 to finish before they can connect. They might still wait a little just because connections take time to make -- you can't avoid that with TCP. And if the server's down, they'll wait an entire 10 minutes before giving up.

2) Use a connectionless protocol, probably UDP. Clients won't have to connect at all, just throwing a packet towards IP address 1.2.3.4 on port 5678 does the job. They won't even wait for the packet to get through, they won't even know if it gets through. The server can read and reply at its leisure.

Last edited by Corona688; 03-31-2011 at 04:41 PM..
# 5  
Old 04-01-2011
Again Corona, thanks for the reply.

What yr saying is not lost on me. Boss/Project Manager is making me keep to these specs. They don't want to spend the time multi-threading this. Their belief is that the server is going to be writing everything it gets to a SQLite DB (read - no transaction manager) and if there is only 1 thread we don't have to create mutexs for access the the DB file (SQLite runs 1 file that it makes act like a DB). So by making sure the sure is only doing 1 thing at a time they believe it helps them. Also the clients are running flat out sniffing the wire, discovering packets and they don't want the client waiting around.

It took me 1.25 days to create the base server class and 1 day for the base client class and they consider that too long - they didn't want to wait another 1-2 days for multi-threading Smilie

Also if a client can't connect it comes back right away.

Thanks for everything - "I luv this site baby - good reading"
Kevin
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

AIX firewall accept established connection

I'm trying to configure a firewall for AIX to accept incoming connections on ports 22 and 443 and deny everything else. All is ok; the server accepts connections only on 22 and 443, but after that I also need to accept all outgoing connections -- ssh and telnet, for example. So I started with ... (0 Replies)
Discussion started by: Michael1457
0 Replies

2. UNIX for Advanced & Expert Users

How keep running a program n an another computer via a connection ssh when the connection is closed?

Hi everybody, I am running a program on a supercomputer via my personal computer through a ssh connection. My program take more than a day to run, so when I left work with my PC I stop the connection with the supercomputer and the program stop. I am wondering if someone know how I can manage... (2 Replies)
Discussion started by: TomTomGre
2 Replies

3. Shell Programming and Scripting

How to ignore requests in dhcpd?

Hi there, I setup a dhcp server on a debian. It is designed to only assign ip addresses to a list of known hosts. The config file looks like : log-facility local6; ignore unknown-clients; subnet 172.16.0.0 netmask 255.255.0.0 { } host 1 { hardware ethernet 00:03:2d:xx:xx:xx; fixed-address... (3 Replies)
Discussion started by: chebarbudo
3 Replies

4. HP-UX

Some I/O requests to this LV are waiting

Hi All I have a blade BL860c running on a C7000 chassis, in which is connected to a NetApp, so lately I am having I/O issues, and dmesg as well as syslog.log is reporting the following: /dev/vg01/lvol2 file system file data error in dev/block 0/55892768 Page I/O error occurred while paging... (2 Replies)
Discussion started by: fretagi
2 Replies

5. Solaris

Solaris 10 ftp connection problem (connection refused, connection timed out)

Hi everyone, I am hoping anyone of you could help me in this weird problem we have in 1 of our Solaris 10 servers. Lately, we have been having some ftp problems in this server. Though it can ping any server within the network, it seems that it can only ftp to a select few. For most servers, the... (4 Replies)
Discussion started by: labdakos
4 Replies

6. Solaris

ip details for interface requests.

Hi All, I have an interface port configured to a FBOL server. This port receives requests from various hosts. I want to know at any moment of time ip addresses of all those hosts from which the requests are coming in. Please help me with command/script. (2 Replies)
Discussion started by: digitalrg
2 Replies

7. UNIX for Advanced & Expert Users

udp sockets of dns requests not showing anywhere...

Dear guys, I am facing the most weird problem I have ever encountered! Ok here is the situation: From my dns query.log file - it is generated using usual bind9 logging: logging { channel query.log { file "/var/log/bind9/query.log" versions 10 size 2m; severity debug 2;... (0 Replies)
Discussion started by: angeloio
0 Replies

8. UNIX for Dummies Questions & Answers

Need to log http requests

Hi folks, I am trying to build this GUI application that will perform some http requests to a specific server. Basically I will use curl to "pretend" that it is a browser a sending an http request from a form. My http knowledge is very low, and the site is tricky, but I think if I could... (3 Replies)
Discussion started by: fundidor
3 Replies
Login or Register to Ask a Question