Socket.AcceptNewConnection
--------------------------

Accepts a new connection and returns a new socket.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Socket](component_Socket.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Socket.AcceptNewConnection"; SocketID ) 

**MBS**( **"Socket.AcceptNewConnection";** /\* Accepts a new connection and returns a new socket. \*/  
**$SocketID**) /\* The socket ID received by [Socket.Connect](SocketConnect.md) function.e.g. $sock \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| SocketID | The socket ID received by [Socket.Connect](SocketConnect.md) function. | $sock |

### Result

Returns new Socket ID or error message.

### Description

Accepts a new connection and returns a new socket.  
### Examples

In the script triggered for a new connection, connect a new socket:

 Set Variable \[$sock ; Value:Get(ScriptParameter)\]  
Set Variable \[$newSock ; Value:MBS ("Socket.AcceptNewConnection"; $sock )\]  
If \[GetAsNumber($newSock )&gt;0\]  
 Set Variable \[$r ; Value:MBS ("[Socket.SetErrorHandler](SocketSetErrorHandler.md)"; $newsock ; Get(FileName); "SocketError")\]  
 Set Variable \[$r ; Value:MBS ("[Socket.SetDataAvailableHandler](SocketSetDataAvailableHandler.md)"; $newsock ; Get(FileName); "ReadSomething")\]  
End If  
### See also

- [Socket.Connect](SocketConnect.md)
- [Socket.Listen](SocketListen.md)
- [Socket.SetDataAvailableHandler](SocketSetDataAvailableHandler.md)
- [Socket.SetErrorHandler](SocketSetErrorHandler.md)
- [Socket.SetNewConnectionEvaluate](SocketSetNewConnectionEvaluate.md)
- [Socket.SetNewConnectionHandler](SocketSetNewConnectionHandler.md)
- [Socket.SetNewConnectionURL](SocketSetNewConnectionURL.md)

### Example Databases

- [Network/HTTP Server hosted](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/HTTP%20Server%20hosted.shtml#3ScriptAnchor_)
- [Network/HTTP Server local](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/HTTP%20Server%20local.shtml#3ScriptAnchor_)
- [Network/Socket Test/Socket Test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/Socket%20Test/Socket%20Test.shtml#3ScriptAnchor_)
- [Network/TCP Send and Receive/TCP Receiver](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Network/TCP%20Send%20and%20Receive/TCP%20Receiver.shtml#3ScriptAnchor_)

This function checks for a license.

Created 18th August 2014 , last changed 26th January 2016

  
[SocialRequest.addMultipartText](SocialRequestaddMultipartText.md) - [Socket.AddMembership](SocketAddMembership.md)

[HTML Version](SocketAcceptNewConnection.shtml)