Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   7.6    Statistic  

Socket.NewTCPSocket

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" )

Parameters

none

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.

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

Example Databases


Socket.Listen   -   Socket.NewUDPSocket

Feedback: Report problem or ask question.




Links
MBS Xojo tutorial videos