Sebastian (塞巴斯蒂安) / 饒漢文 (vorpal) wrote in lj_dev,
Sebastian (塞巴斯蒂安) / 饒漢文
vorpal
lj_dev

  • Mood:

UNIX socket question

I'm pretty new to UNIX socket programming, so bear with me.

This has been bothering me for a long time, and I can't seem to find an easy answer. Say I'm writing a LJ client in C, and I want to log in to LJ. So I make the connection, write the data to the write socket, and then close it. Then I receive data from the read socket, of course. But say I'm working with something like moodids and there's going to be a lot of data returned on the read socket (and not necessarily all in one burst), how do I know when to stop reading from the socket? I can't very well use recv and check if the size is less than 0, because LJ may not have transmitted everything in one send. Is there some way to check whether or not LJ has closed the write end of the socket (i.e. the read part of my socket)? Using poll or something?

Any help would be very much appreciated!
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments