Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Fnet_error

Fnet_error

Enumerations

enum  fnet_error_t {
  FNET_ERR_OK = (0), FNET_ERR_NO_DESC = (-2), FNET_ERR_NOMEM = (-3), FNET_ERR_AGAIN = (-4),
  FNET_ERR_BOUNDREQ = (-5), FNET_ERR_INVAL = (-6), FNET_ERR_DESTADDRREQ = (-7), FNET_ERR_MSGSIZE = (-8),
  FNET_ERR_NOPROTOOPT = (-9), FNET_ERR_PROTONOSUPPORT = (-10), FNET_ERR_OPNOTSUPP = (-11), FNET_ERR_AFNOSUPPORT = (-12),
  FNET_ERR_ADDRINUSE = (-14), FNET_ERR_ADDRNOTAVAIL = (-15), FNET_ERR_NETUNREACH = (-16), FNET_ERR_CONNABORTED = (-17),
  FNET_ERR_CONNRESET = (-18), FNET_ERR_ISCONN = (-19), FNET_ERR_NOTCONN = (-20), FNET_ERR_SHUTDOWN = (-21),
  FNET_ERR_INPROGRESS = (-22), FNET_ERR_TIMEDOUT = (-23), FNET_ERR_HOSTUNREACH = (-24), FNET_ERR_SYSNOTREADY = (-25),
  FNET_ERR_CONNCLOSED = (-26), FNET_ERR_IPDISABLED = (-27), FNET_ERR_BAD_DESC = (-28)
}
 

Possible socket error codes, returned by the fnet_error_get(), or used by the SO_ERROR option.

More...

Functions

fnet_error_t fnet_error_get (void)
 Returns the last error that occurred.
void fnet_error_set (fnet_error_t error)
 Sets the error code.

Detailed Description

When a socket call indicates a failure, it is possible to call the fnet_error_get() function to determine the error value.
Another way to determine the error value for a socket is to examine its SO_ERROR option.
Possible values for socket errors are defined by the fnet_error_t.


Enumeration Type Documentation

Possible socket error codes, returned by the fnet_error_get(), or used by the SO_ERROR option.

Enumerator:
FNET_ERR_OK 

There is no error.

FNET_ERR_NO_DESC 

No more socket descriptors are available.


An application has opened too many sockets. The maximum number of available socket descriptors is defined by the FNET_CFG_SOCKET_MAX.

FNET_ERR_NOMEM 

Cannot allocate the memory.


The error is indicating a lack of required memory resources.

FNET_ERR_AGAIN 

Try again, a retry at some time later may be successful.


This error is returned from operations on sockets that cannot be completed immediately. It is a non-fatal error and the operation should be retried later.
For example, it is normal for the FNET_ERR_AGAIN to be reported as the result from the fnet_socket_connect() calling on a SOCK_STREAM socket, since some time must elapse for the connection to be established.

FNET_ERR_BOUNDREQ 

The socket has not been bound with fnet_socket_bind().


A socket must be bound to an address before calling fnet_socket_getname(), fnet_socket_recvfrom(), fnet_socket_recv(), and fnet_socket_listen().

FNET_ERR_INVAL 

Invalid argument.


An invalid argument was supplied.

FNET_ERR_DESTADDRREQ 

Destination address required.


A required address was omitted from an operation on a socket. For example, this error will be returned, if the fnet_socket_sendto() or fnet_socket_connect() is called with the remote address of INADDR_ANY.

FNET_ERR_MSGSIZE 

Message too long.


A message sent on a datagram socket was larger than the internal message buffer, or some other network limit, or the buffer, which is used to receive a datagram was smaller than the datagram itself.

FNET_ERR_NOPROTOOPT 

Bad protocol option.


An unknown, invalid, or unsupported option or level was specified in the fnet_socket_getopt(), or fnet_socket_setopt() call, or a socket received Parameter Problem ICMP Error Message.

FNET_ERR_PROTONOSUPPORT 

Protocol not supported.


This error occurs if an application attempts to call fnet_socket() and the requested protocol has not been configured into the system, or no implementation for it exists.

FNET_ERR_OPNOTSUPP 

Operation not supported.


The attempted operation is not supported for the type of socket referenced. This occurs, when socket cannot support the requested operation, for example trying to accept a connection on a datagram socket.

FNET_ERR_AFNOSUPPORT 

Address family not supported by the protocol family.


The stack supports only the AF_INET family. This error will be returned, if an address of a wrong family is used for a socket in fnet_socket(), fnet_socket_sendto(), fnet_socket_connect(), fnet_socket_bind(), fnet_socket_getname(), and in fnet_socket_getpeername().

FNET_ERR_ADDRINUSE 

Address already in use.


This error occurs, if an application attempts to fnet_socket_bind() or fnet_socket_connect() a socket to an IP address and port that has already been used for an existing socket, or a socket that wasn't closed properly, or one that is still in the process of closing. Only one usage of each socket address is permitted.

FNET_ERR_ADDRNOTAVAIL 

Cannot assign the requested address.


The requested address is not valid in its context. It normally results from an attempt to fnet_socket_bind() to an address that is not valid for the local machine. This may also result from fnet_socket_connect(), when the remote address or port is not valid for a remote machine (for example address or port is 0).

FNET_ERR_NETUNREACH 

The network is unreachable.


This error occurs, if socket cannot function at this time, because the underlying network interface it uses to provide the network services is unavailable.

FNET_ERR_CONNABORTED 

Software caused the connection abort.


An established connection was aborted due to a data transmission or connection timeouts.

FNET_ERR_CONNRESET 

Connection reset by peer.


A connection was forcibly closed by the remote host. This normally results, if the peer application on the remote host has suddenly stopped, the host has rebooted, or the remote host used a "hard close" on the remote socket.
For the UDP sockets, the remote host was unable to deliver a previously sent UDP datagram and responded with a "Port Unreachable" ICMP packet. The application should close the socket as it is no longer usable.

FNET_ERR_ISCONN 

Socket is already connected.


A fnet_socket_connect() or fnet_socket_listen() request was made on an already connected socket.

FNET_ERR_NOTCONN 

Socket is not connected.


A request to send or receive data was not allowed because the socket is not connected.

FNET_ERR_SHUTDOWN 

The socket has been shut down.


A request to send or receive data was not allowed because the socket had already been shut down in that direction with a previous fnet_socket_shutdown() call.

FNET_ERR_INPROGRESS 

The action is in progress.


An operation was attempted on a socket that already had an operation in progress - in other words calling fnet_socket_connect() a second time on a socket that is already connecting.

FNET_ERR_TIMEDOUT 

The connection has timed out.


A connection attempt failed because the connected party did not properly respond after a period of time.

FNET_ERR_HOSTUNREACH 

No route to a host.


A socket operation was attempted to an unreachable host.

FNET_ERR_SYSNOTREADY 

Network subsystem is unavailable.


The stack is not initialized.

FNET_ERR_CONNCLOSED 

Connection closed by peer.


The final (FIN) segment arrived and there is no data in the socket receive buffer. The remote host closed connection and will not send any data in the current connection.
The application should close the socket as it is no longer usable.

FNET_ERR_IPDISABLED 

IP operation is disabled.


It happens when Duplicate Address Detection fails for interface link-local address, formed from an interface identifier based on the hardware address.

FNET_ERR_BAD_DESC 

Bad socket descriptor.


An operation was attempted on a socket descriptor that does not refer to a valid socket.

Definition at line 43 of file fnet_error.h.


Function Documentation

fnet_error_t fnet_error_get ( void   )

Returns the last error that occurred.

Returns:
This function returns the error code for the last socket operation that failed.
The error codes are defined by the fnet_error_t.
See also:
fnet_error_set()

When a particular socket function indicates that an error has occurred, this function should be called to retrieve the appropriate error code.
A successful socket function call, or a call to fnet_error_get(), does not reset the error code. To reset the error code, use the fnet_error_set() function call with error set to zero (FNET_ERR_OK).

void fnet_error_set ( fnet_error_t  error )

Sets the error code.

Parameters:
errorError code.
See also:
fnet_error_get()

This function is used to set or reset the error code.
Note that any subsequent socket routine called by the application will override the error code, as set by this routine.