How set socket connection Name

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
aetaylorBUSBnWt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Sep 20, 2012 5:11 pm

How set socket connection Name

Post by aetaylorBUSBnWt » Fri Dec 30, 2022 1:34 am

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: How set socket connection Name

Post by mwieder » Sun Jan 01, 2023 5:42 am

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

Post Reply