Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3   9.4    Statistic  


Creates a new TCP Socket.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Socket 3.1 Yes Yes Yes Yes Yes
MBS( "Socket.NewTCPSocket" { ; PreferIPv6 } )   More


Parameter Description Example value
PreferIPv6 Optional
Available in MBS FileMaker Plugin 8.4 or newer.
Pass 1 to get IPv6 or if not available IPv4.
Pass 0 to get IPv4 or if not available IPv6.
Default is 1 for preferring IPv6.


Returns a new socket ID or error message.


Creates a new TCP Socket.
Socket reference numbers are starting at 29000 and counting up for each new socket.

If you call Socket.Connect, you don't need to use this method first as the connect function creates its own socket.
For MBS Plugin 8.3 or newer this may be IPv6 or IPv4 socket.


Create TCP Socket listening on a port:

Set Variable [$$sock; Value:MBS("Socket.NewTCPSocket")]
If [MBS("IsError")]
    Show Custom Dialog ["Failed to create Socket"; $$sock]
    Exit Script []
End If
Set Variable [$r; Value:MBS("Socket.SetNewConnectionHandler"; $$sock; Get(FileName); "NewConnection")]
Set Variable [$r; Value:MBS("Socket.SetErrorHandler"; $$sock; Get(FileName); "SocketError")]
Set Variable [$r; Value:MBS("Socket.Listen"; $$sock; TCP Receiver::ListenPort)]
If [MBS("IsError")]
    Show Custom Dialog ["Failed to create Socket"; $$sock]
    Exit Script []
End If

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 19th September 2018

Socket.LocalPort   -   Socket.NewUDPSocket

Feedback: Report problem or ask question.

MBS Xojo blog