blob: b358718ea07aa4fb8ab97bb7252bb91204646787 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 #include <comm.h>
MG Mud User88f12472016-06-24 23:31:02 +02003 int net_connect(string host, int port)
4
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Open a non-blocking TCP network connection to <host> and
7 <port>. On success, the connection is bound to the current
8 object and the lfun logon() is called in the object.
MG Mud User88f12472016-06-24 23:31:02 +02009
Zesstra715ec202025-07-09 22:18:31 +020010 Returns one of the following values:
11 NC_SUCCESS Success
12 NC_EUNKNOWNHOST the host address could not be resolved
13 NC_ENOSOCKET error during socket creation
14 NC_ENOBIND socket could not be bound
15 NC_ENOCONNECT socket could not be connected
16 (Details of the last three errors can be found in the driver's error
17 log.)
18 NC_ECONNREFUSED remote host not listening/refusing
19 NC_EMCONN too many pending connections (transient, try
20 again later)
21 NC_ENORESSOURCES insufficient system ressources (transient, try
22 again later)
MG Mud User88f12472016-06-24 23:31:02 +020023
Zesstra715ec202025-07-09 22:18:31 +020024 If the driver is configured to support IPv6, <host> is first
25 interpreted as IPv6 hostname. If that fails, <host> is then
26 interpretd as IPv4 hostname.
MG Mud User88f12472016-06-24 23:31:02 +020027
Zesstra715ec202025-07-09 22:18:31 +020028 If the connection can't be established immediately, the efun
29 returns 'success' and the driver will check in the background
30 for the progress of the connection. When it is established,
31 logon() will be called in the object. If the connection fails,
32 logon(-1) will be called in the object.
MG Mud User88f12472016-06-24 23:31:02 +020033
Zesstra715ec202025-07-09 22:18:31 +020034 The efun raises a privilege violation ("net_connect", host, port).
MG Mud User88f12472016-06-24 23:31:02 +020035
Zesstra715ec202025-07-09 22:18:31 +020036BUGS
37 A non-blocking connect() doesn't imply a non-blocking
38 forward name resolution. If you provide a hostname instead
39 of an IP address to connect to, the driver will block until
40 the name is resolved. This may be an issue, depending on how
41 fast your nameserver replies. Non-blocking forward DNS
42 resolution can currently only be achieved using ERQ_LOOKUP.
MG Mud User88f12472016-06-24 23:31:02 +020043
Zesstra715ec202025-07-09 22:18:31 +020044HISTORY
45 First version 1992 by Snake and LynX for Nemesis.
46 Improved 1993 by Junky.
47 Added to LDMud 3.2.10.
48
49SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020050 logon(A)