LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2009, 02:42 AM   #1
laginagesh
Member
 
Registered: Jul 2009
Posts: 42

Rep: Reputation: 16
Exclamation Client - Server problem


Hi,

i have written a Client-Server application.
For new client i am creating client_sockfd

client_sockfd = accept(server_sockfd,(struct sockaddr *)&client_address,&client_len);
FD_SET(client_sockfd,&readfd);

after receiving data from client i am disconnecting the client
FD_CLR(client_sockfd,&readfd);

after disconnecting if the same client is connecting to server it is getting new client_sockfd...How to reuse the same same client_sockfd for the same client again?

for every connection and disconnection client_sockfd changing,after 1024 iterations the server is closing.

cheers
Nagesh

Last edited by laginagesh; 07-28-2009 at 04:17 AM.
 
Old 10-30-2010, 07:24 AM   #2
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Question

Did you mean to mark this "[SOLVED]"?

If so, kindly post the solution -- even though this is an old post, it still might help someone else w/ the same, or a similar, problem.
 
Old 10-31-2010, 11:13 PM   #3
laginagesh
Member
 
Registered: Jul 2009
Posts: 42

Original Poster
Rep: Reputation: 16
With out using close(sockfd) file descriptor will not be free, To use the same file descriptor use close(sockfd)
 
Old 11-01-2010, 12:56 PM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Thanks for responding w/ the solution. That's the LQ spirit.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reuse FD_CLR value laginagesh Linux - Newbie 1 07-28-2009 05:10 AM
Socket reuse ed.poore Programming 5 02-14-2007 04:42 PM
disallow password reuse cambie Linux - Security 0 11-29-2004 01:47 PM
reuse Makefile on different .c? chunlee Linux - Newbie 0 11-06-2004 07:48 PM
Cannot reuse CD-RW after first burn lansman Linux - Newbie 2 11-15-2003 03:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration