× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




I am working on a project where I connect to an outside vendor using
sockets.  I am getting a EBADF - "Descriptor not valid" error when I try
to do a send.  The code that I am using works in other programs.

When you call the socket() API, it returns a number. You then store that number into a variable and later pass it as a parameter to the send() API. Can you verify (by running your program in debug, etc) that the number you got from socket() is the exact same number you're passing to the send() API?

Are you sure the socket hasn't been closed? If you close a socket, but then still try to send data with the send() API, you can get a BADF error.

Another cause that I've seen is when the remote host has disconnected, and your application has already been sent an error code in a previous API call (or in the background on a non-blocking, in progress call, like "connect" does). Since it has already sent you an error telling you that the connection is dead, subsequent calls to the socket APIs can result in EBADF.


I verified that the socket descriptor is consistent in my program. I am not sure what else to check. Any help would be greatly appreciated.

Unless this is actually a network error (which seems unlikely if other programs work) the problem is a bug in your code. Since we haven't seen your code, it's difficult to provide any more specific help than an explanation of what might cause the error.

If my comments (above) don't help, I suggest moving this discussion to the mailing list for the language you've written your program in. (i.e. the RPG400-L mailing list if it's written in RPG, or the C400-L mailing list if it's written in C) and posting a program that we can actually run and see the problem you're encountering.

However, please don't post your entire application (I don't have time to read that much code) just put together a short, simple program that illustrates the problem. Something that I can copy/paste to my machine, compile it, and run it.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.