[uae] Re: I wrote the horrible bsdsocket stuff

  • From: Jeff Shepherd <BeaveMan27@xxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Wed, 07 Apr 2004 20:20:51 -0400

Richard Drummond wrote:

Hi Carl

Nice of you to drop in!

On Wednesday 31 March 2004 02:26 am, Carl Drougge wrote:


..and I wish someone had told me sooner that people were still using it.
(And also that people were using the latest version, even if it isn't much
different. That one is probably my fault though, because it seems all
information of its existance has fallen off the net..)

(Please don't kill me over how horrible it is, it's pretty much the first
thing I wrote in C..)



It isn't very pretty, admittedly, but it works (more or less). ;-)


It's certainly the best solution we have at the moment.



Anyway, I'm planning to see if it can be fixed, or maybe, just maybe,
rewrite it. (I don't have much faith in the windows version, last time I
looked at it it was very windows specific indeed. Admittedly this was four
years ago..)



I had a go fixing a couple of things. And I tried to remove the dependency on pthreads (and use whatever thread layer UAE is using instead). That still has problems, because I haven't done the signal handling - so aborting a socket doesn't work for instance.


I have considered porting the windows version, but while that would be the best solution for maintainability - I'm not convinced it would be technically the best solution. The stack magic code that the win32 version relies on to call Amiga code would cause all kinds of portability problems, IMHO. I think it's a better idea to handle more of the work in the bsdsocket.library wrapper itself as you have done in your version. (BTW, I've been meaning to re-write that in C, since I don't have an E compiler, but haven't got around to it yet).

Cheers,
Rich



I don't think that stack magic code isn't too worrysome. I grep'ed through the source and a bunch of other code does it too (gfxlib.c does a whole lot and native2amiga.c does to get at AllocMem). IMHO, we are emulating the Amiga, why can't we call Amiga code?

I did take a crack at doing a fully-native version of bsdsocket.library. It is a hybrid of the win32 bsdsocket code and the code in bsdsocket-posix.c. It does use the original bsdsocket.[ch] but the backend was written using the code in bsdsocket-posix.c. It does do signal handling so aborting a socket should work (though I haven't tested it yet). I am still working out the kinks but the basics work. I have gotten things like IBrowse and Voyager to work and I am in the process in testing out other programs.

The code is a little rough right now but if people want to look at it I can zip it up and post it to the list.

--
Jeff Shepherd
BeaveMan27@xxxxxxxx


Other related posts: