How to make such a socket?:)
I understood that there are 2 ways:
using IO::Socket
using Fcntl ?
I'm sort of familiar with IO::Socket, and I write simple IRC bots/servers. I thought that:
$sock->autoflush(1);
$| = 1;
makes the socket non-blocking, but a friend of mine just laughed and said that I'm wrong :) He said that I better use Fcntl, but it still could be done with IO::Socket... I'm confused.
Let's say according to me, a non-blocking socket allows other parts of the code to be executed in the same time where the socket is being read or wrote. This is how I do with IO::Socket:
IO::Socket -> create the socket
$sock->autoflush(1);
$| = 1;
while (<$sock> ){
if ($sock =~ /some stuff/){
do(some other stuff);
}
}
So in that way I make simple query-response bots, but nothing more than that.
I want to make simple application: a timer bot. Let's say at every 30 seconds, it writes a line to the socked, and uses time() function. I don't know even where from to start. Somebody give me a direction please?
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.