Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - agena.info

Pages: [1]
1
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 08, 2025, 11:36:31 am »
Thank you for all your kind help. Thank you, indeed. Especially you, Dave on your cool math OS/2 fix.

I just decided to remove all OS/2-related code from Agena. It took me lifetime weeks with all the weird OS/2 quarrels with no avail.

Nobody is using OS/2 any longer. And this is really sad. But I have to accept that.

Alex

2
Hi,

some years ago, a student hired by NMSU had a bad day and re-invented how files should be named at Hobbes.

It is no longer lua-5.4.8, but it is now Lua_5-4-8.

Surprisingly all adhered to the new commands - including me.

No longer !

Alex

3
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 08, 2025, 10:58:47 am »
The ArcaOS development environment I paid EUR 150,- for does not work at all !

Had a nice time with OS/2 - I really loved it - and thank you for all the support you have given.

4
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 07, 2025, 11:45:28 pm »
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

5
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 07, 2025, 11:16:05 pm »
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

6
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 07, 2025, 06:49:18 pm »
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

7
Programming / Re: Networking: socket() returns positive `non-socket`
« on: July 07, 2025, 01:55:49 pm »
Hello,

thanks for your two replies. What I am trying to implement is a simple IPv4 library for a fork of the Lua programming language. What works fine in Windows, Solaris, Linux and Mac obviously does not work with ArcaOS:

1) Have one C function that opens a socket and returns its descriptor, a positive integer, to the Lua environment.

2) Have additional, separate C functions that take the socket descriptor from 1) and that bind, connect, etc.

I guess that as soon as the scope of C function 1) in ArcaOS is left and the interpreter returns to the Lua environment, any info on the socket descriptor is lost and the socket is automatically closed so that all the other functions 2) reject it ?

It only works in ArcaOS if I combine a call to socket() and bind() in one and the same C function, see below, but this does not work for me.

Here are the essential code snippets, compiled with GCC 8.3.0 as follows:

gcc -o agena.exe -s agena.o -L. -lm -lagena -lm -lmapm -lz -lreadline -lncurses -ltinfo  -lhistory -liconv -lexpat -lmpfr -lgmp -lg2 -lgd -lpcre2-posix -lpcre2-8 -lfi_lib -lsocket

#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>

#include <sys/types.h>   /* to be put before sys/socket.h */
#include <stddef.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>  /* must come before arpa/inet.h */
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <unistd.h>

... further Lua-specific includes ...

The following function, successfully returns a positive socket descriptor, mostly starting from 3:

static int net_openos2 (lua_State *L) {
  int sock;
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    errornosock(L, "socket could not be created", "net.openos2");  /* bails out */
  }
  lua_pushinteger(L, sock);
  return 1;
}

The next function net_bindos2, however, rejects the socket descriptor returned by net_openos2, and quits with a `Socket operation on non-socket` error:

static int net_bindos2 (lua_State *L) {
  struct in_addr addr;
  struct sockaddr_in server;
  int port = 1234;
  const char *address = "127.0.0.1";
  int sock = luaL_checkinteger(L, 1);
  if (sock < 2) {
    errornosock(L, "socket is invalid", "net.bindos2");  /* bails out */
  }
  /* initiate binding */
  tools_memset(&server, 0, sizeof(struct sockaddr_in));
  if ((inet_aton(address, &addr)) != 0) {  /* valid address ? */
    tools_memcpy((char *)&server.sin_addr, &addr, sizeof(addr));
  } else {
    errornosock(L, "failure", "net.bindos2");  /* bails out */
  }
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  /* do it */
  if (bind(sock, (struct sockaddr*)&server, sizeof(server)) < 0) {
    agn_neterror(L);  /* bails out */
  }
  lua_pushstring(L, inet_ntoa(server.sin_addr));
  return 1;
}

This one works fine in ArcaOS:

static int net_openandbind (lua_State *L) {
  int sock;
  struct in_addr addr;
  struct sockaddr_in server;
  int port = 1234;
  const char *address = "127.0.0.1";
  /* open socket */
  sock = socket(AF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    errornosock(L, "socket could not be created", "net.openandbind");  /* bails out */
  }
  /* initiate binding */
  tools_memset(&server, 0, sizeof(struct sockaddr_in));
  if ((inet_aton(address, &addr)) != 0) {  /* valid address ? */
    tools_memcpy((char *)&server.sin_addr, &addr, sizeof(addr));
  } else {
    errornosock(L, "failure", "net.bindos2");  /* bails out */
  }
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  /* do it */
  if (bind(sock, (struct sockaddr*)&server, sizeof(server)) < 0) {
    agn_neterror(L);  /* bails out */
  }
  lua_pushinteger(L, sock);
  return 1;
}

8
Programming / Networking: socket() returns positive `non-socket`
« on: July 06, 2025, 08:46:50 am »
Hello,

I am having a big problem with socket programming in C:

Every time I open a socket with:

int sock = socket(AF_INET, SOCK_STREAM, 0);

and try to bind or connect later on I get an 38 error code, claiming that these functions have been called with a non-socket (`Socket operation on non-socket`).

The result returned by socket is always a positive integer, mostly starting from 3.

I even included a call to the undocumented addsockettolist() function after opening the socket, but to no avail.

What am I doing wrong ?  I use ArcaOS 5.0.6 and Paul Smedley's GCC 4.4.6 and 8.3.0. I do not use any OS/2-specific flags like _EMX_TCPIP or TCPV40HDRS in the code (they wouldn't help anyway). Do I need to load any specific TCP/IP-related drivers during boot time other than the ones that are already included in CONFIG.SYS, or do I have to link against additional TCP/IP-specific libraries other than socket (-lsocket flag) ?

The C code that is run on ArcaOS to open, bind, connect, etc. is the very same as with Windows, Solaris, Linux, Mac OS X, where everyting works fine.

Any help would be appreciated.

Thank you,

Alex

9
Networking / Networking: socket() returns positive `non-socket`
« on: July 05, 2025, 07:10:41 pm »
Hello,

I am having a big problem with socket programming in C:

Every time I open a socket with:

int sock = socket(AF_INET, SOCK_STREAM, 0);

and try to bind or connect later on I get an 88 error code, claiming that these functions have been called with a non-socket (`Socket operation on non-socket`).

The result returned by socket is always a positive integer, mostly starting from 3.

I even included a call to the undocumented addsockettolist() function after opening the socket, but to no avail.

What am I doing wrong ?  I use ArcaOS 5.0.6 and Paul Smedley's GCC 4.4.6 and 8.3.0.

The C code that is run on ArcaOS to open, bind, connect, etc. is the very same as with Windows, Solaris, Linux, Mac OS X, where everyting works fine.

Any help would be appreciated.

Thank you,

Alex

Pages: [1]