OS/2, eCS & ArcaOS - Technical > Programming
Networking: socket() returns positive `non-socket`
agena.info:
Hi Dave,
thank you so much for your help and the great tips you have given me over all the many years to get my interpreter running in OS/2.
I just discovered that I have already GCC 9.2.0 installed but any compilation attempt fails because of this `swab`conflict that has been haunting me for years.
I will try all your other tips now.
Thanks again,
Alex
Steven Levine:
Are your C functions statically linked into agena.exe? It's not clear from your example.
If your C functions are linked into agena.exe or are in a DLL linked to agena, baring defects, the code should work as you expect.
While sock only has a value during the function call, you have exported the value to L and I assume the exported value is global and persistent.
I recommend adding a bit of debugging code to printf the value of sock in both functions.
Just returning from a function call is not going to close the socket. The socket will stay open until explicitly closed by your code or when the executable terminates.
You can watch the state of the socket with netstat -s.
To understand how kLIBC maps sockets to file handles see:
src\emx\src\libsocket\socket.c:41
int socket(int af, int type, int protocol)
at
https://github.com/bitwiseworks/libc
agena.info:
Hello Steven,
thank you for your kind answer. It does not work with either statically or dynamcially linked Agena. Checking my vintage OS2World questions about the same subject ten years ago and my change logs, my ipv4 package has actually never worked on OS/2, eCS and ArcaOS.
It's a real pity. I will check your tip on src\emx\src\libsocket\socket.c, though. Maybe it will give me a clue.
> Just returning from a function call is not going to close the socket. The socket will stay open until explicitly closed by your code or when the executable terminates.
Frightening Google AI tells me the very same: a socket assertively is not bound to any scope and can only be closed explicitly by the user, not the OS.
My own experiments, though, tell me the opposite as proven by my own experiments, see above. ArcaOS only shows this strange behaviour. The very same code works beautifully in Windows, Solaris, Linux and Mac OS X, with even Valgrind not complaining about anything there.
Yours,
Alex
Dave Yeo:
--- Quote from: agena.info on July 07, 2025, 06:49:18 pm ---
I just discovered that I have already GCC 9.2.0 installed but any compilation attempt fails because of this `swab`conflict that has been haunting me for years.
--- End quote ---
Hi Alex, what error does the 'swab' conflict give?
agena.info:
Dave,
in file included from agnhlps.c:67:
C:/usr/lib/gcc/i686-pc-os2-emx/9/include-fixed/unistd.h:478:7: error: conflicting types for 'swab'
478 | void swab(const void * __restrict, void __restrictm ssize_t);
In file included from agnhlps.c:14:
C:/usr/include/string.h:122:7: note: previous declaration of 'swab' was here
122 | void swab(const void *, void *, size_t);
The agnhlps.c file is my own collection of primarily math and string-related C functions.
If I initiate Pauls's GCC 4.4.6 or 8.3.0 via
usr\local446\gcc446 or
usr\local830\gcc830
everything is working fine, though, and no such messages show up.
The sources are all here:
https://sourceforge.net/projects/agena/files/Sources/agena-5.1.1-src.tar.gz/download
but surely: do not study them.
Dave, this is not for you but for the ArcaOS team who might read this once upon a time:
I am expecting a fully working out-of-the-box GCC environment for my paid ArcaOS licence, EUR 150.-, not experiencing this weird behaviour, see above:
socket() and bind() in just one C function -> everything is fine
socket() and bind() split upon two C functions -> does not work
Yours,
Alex
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version