Function for opening a server-type UDP communication.
The server remains listening for messages from several stations and responds to each of them if necessary. Listening occurs on the local port specified by nPort and can be limited to the local interface specified by nAddr or extended to all local interfaces.
|
i32 udp_open_server (u32 nPort [, i32 nAddr=ALL])
|
|
Number of the (local) port on which the server is listening
|
|
IP (local) address of the interface on which the server is listening. (optional, default to all local interfaces)
|
|
Returns:
|
|
0-:-99
|
Operation performed successfully. The communication ID is returned
|
-1
|
Illegal nPort
|
-3
|
All task connection table entries are already committed, impossible to establish a new connection (max 10 connections)
|
-1000 -:- -2000
|
Socket opening failed: returns the code provided by the S.O. socket() function, with offset 1000
|
-2000 -:- -3000
|
S.O. function bind() failed: returns the code provided by bind(), with offset 2000
|
To see some returned errors more specifically, see Returned errors table
|
|
Rule, Task
|
|
If the result is negative, it should not be used in the other UDP communication handling functions
|
For a concrete example see in RDE environment: Workspace -> Specials -> Examples Library.
|
|
-1013
|
[EACCES] Permission to create socket of the specified type and protocol denied
|
-1023
|
[ENFILE] System file table is full
|
-1024
|
[EMFILE] Pre-process description table is full
|
-1091
|
[EPROTOTYPE] The socket type is not supported by the protocol
|
-1093
|
[EPROTONOSUPPORT] The protocol family is not supported or the protocol itself is not supported
|
-1097
|
[EAFNOSUPPORT] The domain is not supported
|
-1105
|
[ENOBUFS] Insufficient buffer space
|
-2002
|
[ENOENT] The socket does not exist
|
-2004
|
[EINTR] The connection attempt was aborted
|
-2009
|
[EBADF] Id invalid
|
-2013
|
[EACCES] An attempt was made to make a connection to a broadcast address without the socket having been enabled for broadcast
|
-2014
|
[EFAULT] Has an invalid address
|
-2022
|
[EINVAL] Socket address out of the allowed range
|
-2040
|
[ELOOP] Too many symbolic links encountered during path translation
|
-2088
|
[ENOTSOCK] Invalid id, not referring to a socket
|
-2097
|
[EAFNOSUPPORT] Address does not have a valid address family corrected in its field
|
-2098
|
[EADDRINUSE] Another socket is already listening on the same port
|
-2101
|
[ENETUNREACH] The network is not reachable
|
-2106
|
[EISCONN] The socket is already connected
|
-2110
|
[ETIMEDOUT] Timeout occurred during connection attempt. On request for SYN (n attempts every x seconds) there was no response (server busy)
|
-2111
|
[ECONNREFUSED] There is no one listening on the remote address (on request from SYN the client received an RST sent directly from the server's TCP management when something is wrong) or the server has reached the maximum number of possible connections
|
-2114
|
[EALREADY] The socket is not blocking and a previous connection attempt has not yet concluded
|
-2115
|
[EINPROGRESS] The socket is not blocking and the connection cannot be concluded immediately
|
NOTE: For the complete table of error codes see Error codes functions taking offset into account.
|