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:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
Socket.NewTCPSocket
Creates a new TCP Socket.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| Socket | 3.1 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| PreferIPv6 | 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. |
1 | Optional |
Result
Returns a new socket ID or error message.
Description
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.
Examples
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
- IsError
- Socket.Connect
- Socket.List
- Socket.Listen
- Socket.NewUDPSocket
- Socket.SetErrorHandler
- Socket.SetNewConnectionHandler
Example Databases
- Network/HTTP Server hosted
- Network/HTTP Server local
- Network/Socket Test/Socket Test
- Network/TCP Send and Receive/TCP Receiver
Blog Entries
Release notes
- Version 10.1
- Changed Socket.NewTCPSocket to mark sockets to accept IPv4 connections on IPv6 sockets.
- Version 8.4
- Added PreferIPv6 option to Socket.NewTCPSocket to prefer either IPv4 or IPv6.
Created 18th August 2014, last changed 19th September 2018
Socket.LocalPort - Socket.NewUDPSocket
Feedback: Report problem or ask question.
Links
MBS Xojo PDF Plugins