Error handling in sockets layer.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error handling in sockets layer.

brivero

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:



Can these error codes be directly used with the provided BSD sockets layer? Or I should look for another implementation which returned these error codes? I have had a look in the code and I understand that in the provided socket implementation only a few error codes are returned.

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.

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.

I would thank any recommendation from you dealing with the problem.

Thank you very much.

_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

RE : Error handling in sockets layer.

Frédéric BERNON
Message
Most of sockets should directly return an error code from errno.h (if the return value can be an error code, like in lwip_connect, lwip_bind, etc...). Some others set the global "errno" value. Last, once the socket is created, you can get an error code "per socket" using getsockopt( ...SO_ERROR...), the code you have seen in lwip_socket struct (and the getsockopt call reset the error to 0).
 
I'm not sure which function set such or such error code, but if you see any problems in error handling, send us an email...
 
 
====================================
Frédéric BERNON
HYMATOM SA
Chef de projet informatique
Microsoft Certified Professional
Tél. : +33 (0)4-67-87-61-10
Fax. : +33 (0)4-67-70-85-44
Email : [hidden email]r
Web Site : http://www.hymatom.fr
====================================
P Avant d'imprimer, penser à l'environnement
 

_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Error handling in sockets layer.

Kieran Mansley
In reply to this post by brivero
On Tue, 2007-04-17 at 13:26 +0200, [hidden email] 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



_______________________________________________
lwip-users mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-users