Perl TCP Socket programming vs C recv() function. Do I need to keep track of bytes received? -
I am familiar with TCP / IP programming in C but am new to Pearl. In C. You need to write a loop around your recv () statement, because you do not guarantee to get your data from a revolving server to a revolving server.
i.e.
while (size! = 0) {status = recv (socket, buffer, size, 0); Buffer = buffer + status; Size = size - position; } A lot of all the examples I have seen that Pearl shows you print from the socket without tracking the received bytes.
i.e.
my $ new_sock = $ sock- & gt; accept (); While (& lt; $ new_sock & gt;) {print "$ _ \ n"; } Closed ($ sock); So, do Pearl somehow make sure that you get all your data without computing your bytes?
If the answer is no, then someone might ask me for an example that Pearl is on top of the TCP code which keeps track of my example.
& lt; & Gt; (Readline function) is high level and great for convenience. IO :: Socket supports a RHV method. Received from or IO :: socket from IO: handle : read or might also be interested in sysread methods that simulate a low-level C interface that you are looking for ...
Comments
Post a Comment