Page 1 of 1

How set socket connection Name

Posted: Fri Dec 30, 2022 1:34 am
by aetaylorBUSBnWt
Hello,

While reading the Dictionary it often refers to "connection names" that are associated with a socket - assigned by the accept connection or open socket command.

One can append these connection names to a socketID (ipaddress:port) with a vertical bar "|".

Yet I don't see how to get or set such.

What I do see is that when connecting to a port on a socket server (opened via accept connection) is that the "open socket call returns a different port number than the one sent out with the open socket call.
Using that port number does connect to the socket server - specifically to the port referenced in the open socket call.
I know it does connect to that specific port because my socket server handles multiple ports with different functionality for each port.

But there is no opportunity to further identify the connection with a name that I have found.

So how?

Thanks,
Andrew

Re: How set socket connection Name

Posted: Sun Jan 01, 2023 5:42 am
by mwieder
Two different scenarios here:

When you're opening a remote socket you can assign a name at that time:
The dictionary example is

Code: Select all

open socket to "ftp.example.org:21|sendFiles"
When you're receiving an open socket request via an accept connections request you can't do this.
What you can do is use the remote port address you get from the client when you act on that socket

Code: Select all

write "xyzzy" to socket pRemoteSocket&"|client42"
read from socket "127.0.0.0:20|foo" until linefeed
But you have to manage the names yourself