efl.net: socket, server and dialer for TCP.
Efl.Net.Server defines how to accept new connections, doing the
bind(), listen() and accept() for protocols such as TCP.
Efl.Net.Dialer defines to to reach a server.
Both are based on Efl.Net.Socket as communication interface that is
based on Efl.Io.Reader, Efl.Io.Writer and Efl.Io.Closer, thus being
usable with code such as Efl.Io.Copier.
The Server will emit an event "client,add" with the established
Socket, which is a child and can be closed by both the server or the
user.
The Dialer extends the Socket and allows for creating one given an
address, that will be resolved and connected.
TCP is the initial implementation so we an validate the
interfaces. UDP, Unix-Local and SSL will come later as derivate
classes.
The examples are documented and should cover the basic principles:
- efl_io_copier_example can accept "tcp://IP:PORT" and will work as a
"netcat", can send data from socket, file or stdin to a socket,
file, stdout or stderr.
- efl_net_server_example listens for connections and can either reply
"Hello World!" and take some data or work as an echo-server,
looping back all received data to the user.
More complex interactions that require a "chat" between client and
server will be covered with new classes later, such as a queue that
empties itself once data is read.
2016-08-17 21:53:16 -07:00
|
|
|
class Efl.Net.Server.Tcp (Efl.Net.Server.Fd) {
|
|
|
|
[[A TCP server.
|
|
|
|
|
|
|
|
@since 1.19
|
|
|
|
]]
|
|
|
|
|
2016-10-18 16:24:16 -07:00
|
|
|
methods {
|
|
|
|
@property ipv6_only {
|
|
|
|
[[Whenever IPv6 listen address will accept only same-family clients or will allow IPv4 to connect as well.
|
|
|
|
|
|
|
|
Since Linux 2.4.21, Windows Vista and MacOS X these
|
|
|
|
control whenever a server that did bind to an IPv6
|
|
|
|
address will accept only IPv6 clients or will also
|
|
|
|
accept IPv4 by automatically converting them in an IPv6
|
|
|
|
address, allowing a single socket to handle both
|
|
|
|
protocols.
|
|
|
|
|
|
|
|
If an IPv6 address was used in @Efl.Net.Server.address,
|
|
|
|
this property is $false and an IPv4 connects, then an
|
|
|
|
address such as [::ffff:IPv4]:PORT will be used, such as
|
|
|
|
[::ffff:192.168.0.2]:1234, where the IPv4 address can be
|
|
|
|
extracted.
|
|
|
|
|
|
|
|
If an IPv4 address was used in @Efl.Net.Server.address,
|
|
|
|
this has no effect.
|
|
|
|
|
|
|
|
Systems can configure their default value, usually true
|
|
|
|
(allows only IPv6 clients).
|
|
|
|
]]
|
|
|
|
values {
|
|
|
|
ipv6_only: bool;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
efl.net: socket, server and dialer for TCP.
Efl.Net.Server defines how to accept new connections, doing the
bind(), listen() and accept() for protocols such as TCP.
Efl.Net.Dialer defines to to reach a server.
Both are based on Efl.Net.Socket as communication interface that is
based on Efl.Io.Reader, Efl.Io.Writer and Efl.Io.Closer, thus being
usable with code such as Efl.Io.Copier.
The Server will emit an event "client,add" with the established
Socket, which is a child and can be closed by both the server or the
user.
The Dialer extends the Socket and allows for creating one given an
address, that will be resolved and connected.
TCP is the initial implementation so we an validate the
interfaces. UDP, Unix-Local and SSL will come later as derivate
classes.
The examples are documented and should cover the basic principles:
- efl_io_copier_example can accept "tcp://IP:PORT" and will work as a
"netcat", can send data from socket, file or stdin to a socket,
file, stdout or stderr.
- efl_net_server_example listens for connections and can either reply
"Hello World!" and take some data or work as an echo-server,
looping back all received data to the user.
More complex interactions that require a "chat" between client and
server will be covered with new classes later, such as a queue that
empties itself once data is read.
2016-08-17 21:53:16 -07:00
|
|
|
|
|
|
|
implements {
|
2016-10-20 15:43:02 -07:00
|
|
|
Efl.Object.constructor;
|
efl.net: socket, server and dialer for TCP.
Efl.Net.Server defines how to accept new connections, doing the
bind(), listen() and accept() for protocols such as TCP.
Efl.Net.Dialer defines to to reach a server.
Both are based on Efl.Net.Socket as communication interface that is
based on Efl.Io.Reader, Efl.Io.Writer and Efl.Io.Closer, thus being
usable with code such as Efl.Io.Copier.
The Server will emit an event "client,add" with the established
Socket, which is a child and can be closed by both the server or the
user.
The Dialer extends the Socket and allows for creating one given an
address, that will be resolved and connected.
TCP is the initial implementation so we an validate the
interfaces. UDP, Unix-Local and SSL will come later as derivate
classes.
The examples are documented and should cover the basic principles:
- efl_io_copier_example can accept "tcp://IP:PORT" and will work as a
"netcat", can send data from socket, file or stdin to a socket,
file, stdout or stderr.
- efl_net_server_example listens for connections and can either reply
"Hello World!" and take some data or work as an echo-server,
looping back all received data to the user.
More complex interactions that require a "chat" between client and
server will be covered with new classes later, such as a queue that
empties itself once data is read.
2016-08-17 21:53:16 -07:00
|
|
|
Efl.Net.Server.serve;
|
|
|
|
Efl.Net.Server.Fd.client_add;
|
|
|
|
Efl.Net.Server.Fd.client_reject;
|
|
|
|
}
|
|
|
|
}
|