Hello, I have a bit of legacy code that I want to avoid
changing as much as possible:
my $iaddr = &inet_aton("$sname") || return 5;
socket(SH,PF_INET,SOCK_STREAM,getprotobyname('tcp'));
connect(SH,sockaddr_in($port,$iaddr))
|| return 6;
The issue is that I want to modify the amount of time
that I am spending waiting for the connect before I timeout.
I think that I can use setsockopt to do this. Reading the
unix setsockopt (2) manpage (Using FreeBSD 4.1.1-STABLE),
it appears that there are two
variables associated with timeouts:
SO_SNDTIMEO set timeout value for output
SO_RCVTIMEO set timeout value for input
My Questions:
- Do either of these affect the timeout for a connect or
do they only apply to connected sockets?
- If not, what is the correct way to set the connect timeout (if it can be
done)?
- According to man setsockopt, these options require
a timeval struct in c to work, what is the correct data
structure to modify these options with the perl setsockopt?
Note: Yes, I know, I could do all this so much
easier with IO::Socket, but let's just assume that is not
an option here.
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.