Difference between revisions of "MC-Basic:ACCEPT"
m (Text replace - "Versions 4.0.14 and higher" to "Since Version 4.0.14") |
|||
Line 50: | Line 50: | ||
Accept(#1,65456) | Accept(#1,65456) | ||
− | '''EXAMPLE - | + | '''EXAMPLE - Since Version 4.0.14''': |
Dim X as long = 2 | Dim X as long = 2 |
Revision as of 16:49, 20 March 2014
Binds a TCP socket to specific port and accepts a connection. Listens to a TCP socket. The <port number> defines TCP port.
Syntax
Accept({#<listening device number>}, #<accepting device number>, <port number>)
Type
<listening device number>: Long
<accepting device number>: Long
<port number>: Long
Range
<listening device number>: 1 to 255
<accepting device number>: 1 to 255
<port number>: 6000 through 6999
Scope
Task
Limitations
Task only
Errors:
- Invalid socket
- Cannot accept connection
Examples
EXAMPLE
Accept(#1,65456)
EXAMPLE - Since Version 4.0.14:
Dim X as long = 2
OpenSocket Options=1 as #1 ‘explicit socket open for listening for port
while TRUE
OpenSocket Options=1 as #X ‘explicit socket open for listening accepting a new connection
Accept(#1, #X, 6002)
X=X+1
End while
Where:
- Listening device is permanent and bound to the port. It can be closed only when listener is terminated.
- Accepting device[x] is created each time a listener creates new server task.
- Application cannot close accepting device[x] when it is accepting.