AnyEvent::TFTPd::Connection - Represents one connection to TFTPd


NAME

AnyEvent::TFTPd::Connection - Represents one connection to TFTPd


DESCRIPTION


SYNOPSIS


ATTRIBUTES

peername

Holds the sockaddr of the remote host.

address

Holds a human readable version of the address part of peername.

port

Holds a human readable version of the port part of peername.

opcode

A numeric representation of the opcode which initiated the connection.

mode

Either "ascii" or "octet" or empty string if unknown.

file

A string representing the requested file from client.

filehandle

The filehandle used to read/write data from/to client.

rfc

Contains extra parameters the client has provided. These parameters are stored in a hash ref.

server

A reference back to the the AnyEvent::TFTPd manpage object.

connected_at

The time the connection was established. Epoch timestamp.

packet_number

The current packet number received/sent.

retries

The number of retries left before aborting the transmission.


METHODS

send_packet

This method will send a packet of data from filehandle to client, identified by peername. The packet is calculated using the MIN_BLKSIZE and packet_number. Returns 1 on success, 2 if this is the last packet to be sent, 0 if something went wrong and -1 no more data is available from filehandle.

receive_ack

This method will receive a datagram and unwraps the packet number from it using unpack("n"). It will increase the packet_number if the received packet number matches packet_number.

Will always call send_packet and return the value it returns. A return value of -1 indicates that the last ACK was received and the connection can be "shut down".

receive_packet

This method will receive a datagram and unwraps the packet number and body from it using unpack("na*"). It stores the data in the current filehandle if the packet number equals packet_number. It returns 1 on success, 0 on failure and -1 if this was the last packet to be received. The latter indicates that it is safe for this connection to "shut down".

send_ack

This method is called inside receive_packet() and is used to tell the peer that a packet is received.

send_error

Takes a "name" indicating a type of error, which is looked up from the %ERROR_CODES variable (see the source for details). Falls back to "not_defined", if an invalid name was passed on. Packs the data from %ERROR_CODES and pass it to the remote client. Returns 1 on success and 1 on failure.

logf

 $self->logf($connection_obj, @message);

Receives internal log messages and (maybe) a connection object. Is meant to be overriden when subclassing this module.


BUGS


COPYRIGHT & LICENSE


AUTHOR

See the Top::Module manpage.

 AnyEvent::TFTPd::Connection - Represents one connection to TFTPd