Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 12.2   12.3   12.4   12.5   13.0   13.1   13.2   13.3   13.4   13.5    Statistic    FMM    Blog  

Socket.LocalPort

Queries local port number.

Component Version macOS Windows Linux Server iOS SDK
Socket 8.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Socket.LocalPort"; SocketID )   More

Parameters

Parameter Description Example
SocketID The socket ID received by Socket.Connect function. $sock

Result

Returns number or error.

Description

Queries local port number.
This is usually 0 for a brand new socket.
Does not work on Windows 7 or older (requires Vista on Windows).

Examples

Get local port and IP:

Set Variable [ $sock ; Value: MBS("Socket.Connect"; "monkeybreadsoftware.com"; 80) ]
Set Variable [ $$LocalPort ; Value: MBS( "Socket.LocalPort"; $sock ) ]
Set Variable [ $$LocalIP ; Value: MBS( "Socket.LocalIP"; $sock ) ]
Set Variable [ $r ; Value: MBS("Socket.Close"; $sock) ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 28th December 2017, last changed 4th March 2023


Socket.LocalIP - Socket.NewTCPSocket

💬 Ask a question or report a problem