Hi, when reading data from a TCP socket, how do I tell when I have received all the data I should have received?
Particularly, I´m trying to read data sent by a web server, so I´m opening a socket, send an HTTP request and receive an answer. Apparently I need to read from the socket in an endless loop. I really don´t like that because it blocks the program and creates 100% CPU load, and I can´t tell if there is more data to be read or not. It doesn´t seem wise to rely on the Content-Length: header to figure out whether I received all data or not. I guess I´m doing it all wrong because I couldn´t find a documentation about using sockets which isn´t anything but confusing and leaves lots of questions. I also guess I need something event-driven, i. e. send a request, and in the event that the server sends data, somehow receive it in the background. The application would need to do a few things in the background because there would be several types of events. Forking a process for every event doesn´t seem right, and it provides me with the problem of exchanging data between the various processes (at least unless I let every process do its job and exit and fork another one to do basically the same thing again). Is perl the wrong language to do this? What would you suggest? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/