LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2007, 09:43 AM   #1
Santoshkb
Member
 
Registered: Sep 2007
Posts: 56

Rep: Reputation: 15
How can we get to know data on socket?


client wants to recv(read) data, when server sends,

I cant use while (1) (recv()!= -1) as client also handles task of sending data.continuously,
i.e sending is constant, but when data is available, want to read, and take action,



awaiting for your valuable suggestion.

thanks
 
Old 10-05-2007, 12:43 PM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
There are a few different ways of doing this.

1) Have 2 threads. 1 for reading, and 1 for writing. Most clean

2) Use non-blocking sockets, check return codes from recv to determine if data was read. Psuedo messy

3) Use select() to check for data availability. Sortof messy, but can be clean.

Those are the best options I can come up with.
 
  


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
methods to know data on socket? Santoshkb Linux - Server 0 10-05-2007 09:38 AM
Read data from a socket allomeen Linux - Networking 1 05-08-2006 03:19 AM
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
problems receving data in socket programming stephenwalter Programming 5 09-29-2005 11:58 PM
Receiving all data from socket Ohmu Programming 6 03-08-2004 01:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:27 AM.

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