OpenQNX :: The QNX Community Portal

Aug 08, 2008 - 12:48 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 37 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
zhenwang
Post subject: Question about socketpair  PostPosted: Apr 16, 2008 - 09:39 PM
New Member


Joined: Apr 16, 2008
Posts: 3

Does anyone know of any way to write to a socket and block until the data has been read at the other end?

Apparently, the socket has some sort of receiving/sending buffer (SO_RCVBUF/SO_SNDBUF options), I was thinking maybe we can change the value to block write(). So I tried setting the buffer size to 1 byte, and for some reason it doesn't work: setsockopt() returned correctly, but write() function was not blocked anyway. I also tried buffer size 16 and 64 byte, they didn't work either.

Any idea?

Thanks.

//*************** Code ***************************
int size = 1;
if (setsockopt(fda[0], SOL_SOCKET, SO_RCVBUF, &size, sizeof(int)) < 0){
cout << "something is wrong" << endl;
}

if (setsockopt(fda[1], SOL_SOCKET, SO_SNDBUF, &size, sizeof(int)) < 0){
cout << "something is wrong" << endl;
}
 
 View user's profile Send private message  
Reply with quote Back to top
Tim
Post subject:   PostPosted: Apr 17, 2008 - 02:13 PM
Senior Member


Joined: Mar 10, 2004
Posts: 546

Zhenwang,

You didn't mention whether you were using UDP or TCP sockets. Not that it matters much either way.

With sockets there is no way to know when the data has been read at the other end unless the remote application sends back an acknowledgement packet to your application.

In other words, your apps have to do all of that work (or you can use QNET if both sides are running QNX).

Tim
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
zhenwang
Post subject:   PostPosted: Apr 17, 2008 - 03:41 PM
New Member


Joined: Apr 16, 2008
Posts: 3

Thanks.

I was actually trying to use it as a local socket stream, as

socketpair(AF_LOCAL, SOCK_STREAM, 0, fda) ;
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject:   PostPosted: Apr 17, 2008 - 09:06 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2812

Did trust my answer on community.qnx.com, lol !
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.