LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
 
LinkBack Search this Thread
Old 03-29-2007, 01:08 PM   #1
dhara
LQ Newbie
 
Registered: Jan 2007
Posts: 4

Rep: Reputation: 0
Post Creating threads -Block in accept !


hello friends,
I have several clients and for each i open one thread.The thread does the reading writing stuff. My code worked fine when i started the server first and then the client. But now my requirement is to start the client first.In that case the same code blocks after the first client has been served.Is accept() blocking? Here is my code..

/********Server*************/
void fuction()
{
.......
....... //tcp socket created

for(i=0;i<nthreads;i++)
{
newsok=accept(tcpsok,(struct sockaddr*)&cli_addr,&cli_len);

if(newsok<0)
{
printf("\n Error in accept function ");
exit(0);
}
else
printf("\n Accept OK");
pthread_create(&tid_produce[i],NULL,&produce,(void *)newsok);
}
}
The produce function in turn calls another function.Plz help me out!!
 
Old 03-29-2007, 11:51 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Just out of curiosity, why are you required to start the client first?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Threads lucky6969b Linux - Software 2 12-02-2005 01:44 AM
Creating Linux Threads in C++ George_gk Programming 2 01-27-2005 03:29 AM
Creating a milisecond timeout timer for threads cardias Programming 5 08-05-2004 07:18 AM
Problems creating a milisecond timeout timer for threads cardias Linux - Software 1 08-04-2004 03:10 PM
Problem with USB Key and creating the /dev/sda1 block device Ben2210 Slackware 5 08-04-2004 02:42 AM


All times are GMT -5. The time now is 08:29 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration