lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Error handling in sockets layer.


From: Kieran Mansley
Subject: Re: [lwip-users] Error handling in sockets layer.
Date: Tue, 17 Apr 2007 13:36:30 +0100

On Tue, 2007-04-17 at 13:26 +0200, address@hidden wrote:
> 
> Hello, 
> 
> I am interesting in handling errors when using the sockets layer
> functions of LWIP. 
> 
> I have already read the pdf documentation where it is said that the
> BSD socket library provides no such error handling due to the fact
> that it is a simple reference implementation. But I have also seen in
> the code that there is an error table already defined: 

Those are the error numbers that are used internally in lwIP.  If you're
using the sockets API you shouldn't be using those directly.  lwIP
translates any errors through the sockets API into more standard error
numbers using the err_to_errno_table in src/api/sockets.c.  This uses
the OS defined error numbers, which you can optionally specify in arch.h
for your port - see for example src/include/lwip/arch.h 

> Actually, I vas making a comparison with the win32 socket
> implementation, and I would like to achieve a function similar to that
> WSAGetLastError in win32 for those who are familiar to the platform.  

The lwIP sockets API is designed to be similar to the BSD/unix/linux
sockets API.  Winsock is really rather different in many ways, and
although it has similar functionality it's a completely different API.  

> I have also seen that in the socket structure below (lwip_socket),
> there are sometimes used some of these codes (in err), and I think
> that this structure might should be read to make a proper error
> handling. 

You shouldn't need to look at the internal lwip structures such as
lwip_socket to determine what the error conditions are.  Normally a
function will modify its return code to signify that an error has
occurred, and you would then check the special errno global variable in
C to determine what the error was.

Kieran 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]