Difference between revisions of "MC-Basic:ACCEPT"

From SoftMC-Wiki
Jump to: navigation, search
m (1 revision)
 
(32 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Languages|MC-Basic:ACCEPT}}
 
{{MC-Basic
 
{{MC-Basic
 
|SHORT FORM=
 
|SHORT FORM=
Line 4: Line 5:
  
 
|SYNTAX=
 
|SYNTAX=
Accept( ''{#<ListeningDevice number>}'' , #<''Accepting device number''>, <''port number''>)
+
Accept({#<''listening device number''>}, #<''accepting device number''>, <''port number''>)
  
 
|AVAILABILITY=
 
|AVAILABILITY=
Line 10: Line 11:
  
 
|DESCRIPTION=
 
|DESCRIPTION=
Binds a TCP socket to specific port and accepts a connection. Listens to a TCP socket. The <''port number''> defines TCP port
+
Binds a TCP socket to specific port and accepts a connection. Listens to a TCP socket.
 +
The <''port number''> defines TCP port.
  
 
|TYPE=
 
|TYPE=
<''Listeningdevice number''> : Long
+
<''listening device number''>: Long
  
<''Acceptingdevice number''> : Long<br>
+
<''accepting device number''>: Long<br>
  
<''port number''> : Long
+
<''port number''>: Long
  
  
  
 
|RANGE=
 
|RANGE=
<'' Listening device number''> :  1 to 255
+
<''listening device number''>:  1 to 255
  
<'' Accepting device number''> :  1 to 255<br>
+
<''accepting device number''>:  1 to 255<br>
  
<''port number''> :  6000 through 6999
+
<''port number''>:  6000 through 6999
  
 
|UNITS=
 
|UNITS=
Line 40: Line 42:
 
Task only
 
Task only
  
Errors                  Invalid socket<br>
+
Errors:
  
Cannot accept connection
+
*Invalid socket<br>
 +
*Cannot accept connection
  
 
|EXAMPLE=
 
|EXAMPLE=
 +
'''EXAMPLE'''
 +
 
Accept(#1,65456)
 
Accept(#1,65456)
  
Or  for Versions 4.0.14 and higher :
+
'''EXAMPLE - Since Version 4.0.14''':
  
 
Dim X as long = 2
 
Dim X as long = 2
  
OpenSocket Options=1 as #1 ‘explicit socket open for listening for port
+
OpenSocket Options=1 as #1 'explicit socket open for listening for port
  
 
while TRUE
 
while TRUE
  
OpenSocket Options=1 as #X explicit socket open for listening accepting a
+
OpenSocket Options=1 as #X 'explicit socket open for listening accepting a new  connection
 
 
new  connection
 
  
 
Accept(#1, #X, 6002)
 
Accept(#1, #X, 6002)
Line 65: Line 68:
 
End while
 
End while
  
Where the rules are
+
'''Where''':
 
+
* Listening device is permanent and bound to the port. It can be closed only when listener is terminated.
1.      ListeningDevice is permanent and bound to the port it can be closed only when listener terminated
+
* Accepting device[x] is created each time a listener creates new server task.
 
+
* Application cannot close accepting device[x] when it is accepting.
2.      AcceptingDevice[x] is created every time when listener creates new server task
 
 
 
3.      Application shall not close     AcceptingDevice[x] when it is in accept
 
  
 
|SEE ALSO=
 
|SEE ALSO=
* [[Axystems:MC-Basic:CLOSE|CLOSE]]
+
* [[MC-Basic:CLOSE|CLOSE]]
* [[Axystems:MC-Basic:CONNECT|CONNECT]]
+
* [[MC-Basic:CONNECT|CONNECT]]
* [[Axystems:MC-Basic:OPENSOCKET|OPENSOCKET]]
+
* [[MC-Basic:OPENSOCKET|OPENSOCKET]]
* [[Axystems:MC-Basic:PING|PING]]
+
* [[MC-Basic:PING|PING]]
 
+
<!-- [[Category:MC-Basic:Communication|ACCEPT]] -->
 
 
 
}}
 
}}

Latest revision as of 09:50, 18 July 2019

Language: English  • 中文(简体)‎

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.

See Also