nettobac  0.0.0
Network features for FreeBASIC code
Error Messages

Each nettobac instance (either nettobacClient or nettobacServer) contains a member variable called Errr, inherrited from n2bFactory. This variable is the error indicator and an error message at the same time:

  • its value is 0 (zero) in case of successful operations, otherwise it gets any value
  • the value points to a static ZSTRING containing information where the error occured

An error check and the output of a human readable error message gets generated by (assuming the code is enclosed by a WITH Instance block)

IF .Errr THEN ?"error: " & *.Errr & " failed" : .Errr = 0

See macro ERR_MSG and its usage for an advanced example.

Note
Ths static string n2bFactory.Errr is owned by nettobac. Never change or free that string.
nettobac does not reset this variable. You have to do it in your code when you intend to continue after an error occured. (Otherwise your next error check may trough a false positive.)

Furthermore, when the issue comes from a libc function call, you can gain detailed information from its errno.

The following sections list all manner of .Errr strings reported by nettobac.

nettobacClient

  • "client resolve IP": message from the constructor nettobacClient::nettobacClient(). It failed to resolve the IP adress of the server –> Check libc errno. Check your network connection and configuration, especialy the name server settings.
  • "client connect": message from the constructor nettobacClient::nettobacClient(). It failed to connect to the servers IP adress –> Check libc errno. Check your network connection.
  • "client socket check": message from function nettobacClient::nOpen(). It failed to use the socket created in the constructor –> Check the error message from the constructor.

nettobacServer

  • "server bind": message from the constructor nettobacServer::nettobacServer(). It failed to assign a local socket address to the socket –> Check libc errno. Check your network connection.
  • "server listen": message from the constructor nettobacServer::nettobacServer(). It failed to listen for socket connections at the port –> Check libc errno. Check your network connection.
  • "server select": message from function nettobacServer::nOpen(). It failed to select the socket for read access. –> Check libc errno. Check your network connection.
  • "server isset": message from function nettobacServer::nOpen(). It failed to find pending data at the port. –> Usually this means there is no pending client connection request. You can ignore that message. Otherwise check libc errno.
  • "server accept": message from function nettobacServer::nOpen(). It failed to accept the new client connection on the socket –> Check libc errno. Check your network connection.

n2bFactory

  • "opensocket": message from the constructor n2bFactory::n2bFactory(). It failed to open a new socket for this instance –> Check libc errno. Check your network connection.
  • "find connection": message from function n2bFactory::nClose(). It failed to find the connection in the list of open connections. –> Check the pointer value. Check if the connection gets closed at an other place in your code, before.

n2bConnection

  • "setsockopt": message from the constructor n2bConnection::n2bConnection(). It failed to set options for the socket –> Anything went totaly wrong. Check libc errno. Good luck to find the bug.
  • "put socket check": message from function n2bConnection::nPut(). It failed checking the socket identifier. –> Anything went totaly wrong. Check libc errno. Good luck to find the bug.
  • "get socket check": message from function n2bConnection::nGet(). It failed checking the socket identifier. –> Anything went totaly wrong. Check libc errno. Good luck to find the bug.
  • "put data check": message from function n2bConnection::nPut(). It failed checking the data to send. Either the pointer to the data Dat is zero or the length Az is zero. –> Pass correct parameters to the function.
  • "select": message from function n2bConnection::nGet() or n2bConnection::nPut(). It failed to select the socket. –> Check libc errno. Check your network connection.
  • "retry": message from function n2bConnection::nGet() or n2bConnection::nPut(). It failed to receive or send data, since the maximum number of re-tries is reached –> Check your network connection. Increase the parameter ReTry for bad connections.
  • "send data": message from function n2bConnection::nPut(). It failed to send data over the socket –> Check libc errno. Check your network connection.
  • "receive data": message from function n2bConnection::nGet(). It failed to receive data from the socket –> Check libc errno. Check your network connection.
  • "disconnected": message from function n2bConnection::nGet(). It failed to get data from the socket –> Your peer closed that connection. You cannot use it any more, close it as well.