The flag is the bit OR of several valid values. For example, the flag can be set to MSG_PEEK, if you use that value with recv, recv() will only peek at the buffer, but will not remove data from the buffer:
use IO::Socket::INET; use strict; use warnings; my $s = IO::Socket::INET->new(Proto=>"tcp", PeerAddr => "www.yahoo.com +", PeerPort => 80); print $s "GET / HTTP/1.1\r\nHost: www.yahoo.com\r\n\r\n"; my $foo; for (1..5) { recv $s, $foo, 15, MSG_PEEK; print "========\n"; print $foo; print "\n"; }
If you run the above code, you will keep getting the first 15 bytes of the response:
======== HTTP/1.1 200 OK ======== HTTP/1.1 200 OK ======== HTTP/1.1 200 OK ======== HTTP/1.1 200 OK ======== HTTP/1.1 200 OK
In reply to Re: 'flags' parameter of socket send()
by pg
in thread 'flags' parameter of socket send()
by iKnowNothing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |