char *h_name; /* official name of host */
char **h_aliases; /* alias list */
ListIPAddress AddressList;
long h_addrtype; /* host address type */
long h_length; /* length of address */
I think this comes from the fact you cannot "share" bsdsocket data from one process to another. The Process that creates the socket is the only one able to work on that socket.
This is mentioned in the autodoc IIRC.
Simon
Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such. ---- http://codebench.co.uk
In your code I can't see where you are opening bsdsocket.library and obtaining its interface. You quoted some threading code so despite your other code does not seem to use it I assume you do in your actual program, so this may be your problem, and even then remember sockets are *not* shareable across processes by default, you'll need to either write a socket server either enable the sharing functionnality in bsdsocket (see Autodocs). Also remember that each process *must* open/close its own libraries/interfaces.
yes the ISocket Interface is created, in the main program, but then, the thread does Obtain() the ISocket before use.
No you need to open bsdsocket.library and GetInterface() in each thread. Except for rare exceptions Obtain() and Release() are called internally by GetInterface() and DropInteface() they shouldn't be called by program code.
No you need to open bsdsocket.library and GetInterface() in each thread. Except for rare exceptions Obtain() and Release() are called internally by GetInterface() and DropInteface() they shouldn't be called by program code.
You can call Obtain()/Release() directly, see exec GetInterface() autodoc for an example with threads.
Even if RoadShow would store it's per process data in ISocket instead of SocketBase, which isn't the case, using ISocket->Obtain() wouldn't have worked since that just increases the usage count. For libraries with per process data in the interface you have to use something like thread_IFoobar = global_IFoobar->Clone() instead.
and even then remember sockets are *not* shareable across processes by default, you'll need to either write a socket server either enable the sharing functionnality in bsdsocket (see Autodocs). Also remember that each process *must* open/close its own libraries/interfaces.
Thank you, the sharing functionality was not clear from reading the Autodocs but I figured it out in the end. The problem whit Autodocs here was that did not explain, that I need bout command, and it did not explain where to use what command.
It was a bit of try and fail, and try again, and then it worked.
As the socket object, has to have the right interfaces, so functions can be called from the object, I created method to set it. This was the perfect place to hide orbiting the socket.
When my Ami C++ Class Framework is ready it will be shared, the Framework will make it easier to port code between AmigaOS and Windows for cross platform applications.
Edited by LiveForIt on 2014/3/3 16:21:13
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Thank you, the sharing functionality was not clear from reading the Autodocs but I figured it out in the end. The problem whit Autodocs here was that did not explain, that I need bout command, and it did not explain where to use what command.
It's explained in OpenLibrary() and SocketBaseTags()
I'm really not sure you should those two functions as they seem to make the sockets public. That could result in another program using your socket! (unless I missunderstand the meaning of public in this context).
I'm not 100% of the usage of SocketbaseTags() in this cobnteaxt as I only ever worked with the open SocketBase for each process approach (which is the recomended approach) but I think you'd open the library and then call
I'm really not sure you should those two functions as they seem to make the sockets public. That could result in another program using your socket! (unless I misunderstand the meaning of public in this context).
yes they become public, and gets a unique id, unless there are other programs that know about uniqueid they can not obtain it.
For a process to use a File Descriptor it has to be in the Process File Descriptor list, so before its obtained no one can use it.
That will most likely only solve Library base / interface problem. But as File Descriptor as liked to one process or the other, it probeable want solve that issue.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Sorry you slightly confused me (maybe more than slightly :-0) we were talking about Sockets? Where did the file descriptors come from? File descriptors and sockets are not related unless you live in the loonixverse.
What kind of file descriptor? DOS? Unless I'm mistaken you can write a DOS filehandle from any process. Or newlib ? In that case you must make sure all subprocesses are started with NP_Child, then you can share them.
its in the name socketfd = socket file descriptor. it's inheritance a socket, really is file descriptor, but you don't think about it that way.
The bsdsocket.library sockets aren't stored in a process specific structure but in the SocketBase, but you can't use them from a process other than the one which called IExec->OpenLibrary("bsdsocket.library", ...), unless you enable SocketBase sharing with SBTC_CAN_SHARE_LIBRARY_BASES.
To me it sound like its process file table, and its says porcess. you know the ins and outs, I know what I read.
So is the documentation wrong?
There is also number of references to fd (file descriptor), not sd (socket descriptor), in the autodocs. Maybe I live in the loonixverse, but I know who put me there.
long ObtainSocket(long id, long domain, long type, long protocol);
FUNCTION
This function is for passing control of a socket from one process
to another. The socket to be handed over must be identified by
an ID, a domain, type and protocol number.
RESULT
A -1 is returned if an error occurs, otherwise the return value is a
descriptor referencing the socket.
ERRORS
The ObtainSocket() call fails if:
[EBADF]
No socket with the given Id could be found.
[EPROTONOSUPPORT]
The protocol type or the specified protocol is not
supported within this domain.
[EMFILE]
The per-process descriptor table is full.
[ENFILE]
The system file table is full.
[EACCESS]
Permission to create a socket of the specified type
and/or protocol is denied.
[ENOBUFS]
Insufficient buffer space is available. The socket
cannot be created until sufficient resources are
freed.
SEE ALSO
socket(), accept(), bind(), connect(), getsockname(),
getsockopt(), IoctlSocket(), listen(), recv(), WaitSelect(),
send(), shutdown(), ReleaseSocket()
Edited by LiveForIt on 2014/3/3 18:26:54
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Partially, it seems it just wasn't updated when SocketBase sharing was added, before it was added to RoadShow each process had to open it's own SocketBase and the only way to use sockets in different processes was to move a socket from one SocketBase to another one using ReleaseSocket() (removes it from the SocketBase used by the current process, usually the parent process) + ObtainSocket() (adds it to the SocketBase used by the current process, usually a child process of the one which released the socket).
Quote:
There is also number of references to fd (file descriptor), not sd (socket descriptor), in the autodocs.
Some of the docs were probably taken directly from the docs of the BSD4.3 TCP/IP stack on which RoadShow is based without changes, on Unix (and in the AmigaOS C library functions) there is no difference between file and socket descriptors. The error defines can't be changed, for example from EMFILE to EMSOCKET, or it would be incompatible to other systems.