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.Listen
Binds the socket to the port and starts listening.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| Socket | 3.1 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| SocketID | The socket ID received by Socket.Connect function. | $sock | |
| Port | The port number to listen at. | 8000 | |
| backlog | Available in MBS FileMaker Plugin 9.1 or newer. The back log for connection. How many pending connections can be accepted on this socket. Once you call Socket.AcceptNewConnection, an entry is removed here. Default is 3. |
3 | Optional |
Result
Returns OK or error message.
Description
Binds the socket to the port and starts listening.For UDP Socket, the socket starts receiving packets.
For TCP Socket, the socket can accept connections which causes a script to be called. You set the script name with Socket.SetNewConnectionHandler. In the script you call Socket.AcceptNewConnection to get a new socket for the new connection.
Be aware that FileMaker Server does not allow the plugin to operate if no script is running. So if you use sockets there, make sure a script is running or paused while you expect an answer coming in.
Examples
Listen to a given Port:
Set Variable [$r; Value:MBS("Socket.Listen"; $$sock; 12345)]
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.AcceptNewConnection
- Socket.Connect
- Socket.IsListening
- Socket.List
- Socket.NewTCPSocket
- 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
- Network/UDP/UDP Broadcast
- Network/UDP/UDP Receiver
Blog Entries
- Neues MBS FileMaker Plugin 9.1
- MBS FileMaker Plugin 9.1 - More than 5700 Functions In One Plugin
- MBS FileMaker Plugin, version 9.1pr6
Release notes
- Version 9.1
- Added backlog parameter for Socket.Listen.
Created 18th August 2014, last changed 4th March 2019
Feedback: Report problem or ask question.
Links
MBS Xojo blog