Difference between revisions of "MC-Basic:ACCEPT"

From SoftMC-Wiki
Jump to: navigation, search
Line 4: Line 4:
  
 
|SYNTAX=
 
|SYNTAX=
Accept( ''{#<ListeningDevice number>}'' , #<''Accepting device number''>, <''port number''>)
+
Accept( ''{#<Listening Device number>}'' , #<''Accepting device number''>, <''port number''>)
  
 
|AVAILABILITY=
 
|AVAILABILITY=
Line 13: Line 13:
  
 
|TYPE=
 
|TYPE=
<''Listeningdevice number''> : Long
+
<''Listening device number''> : Long
  
<''Acceptingdevice number''> : Long<br>
+
<''Accepting device number''> : Long<br>
  
<''port number''> : Long
+
<''Port number''> : Long
  
  
Line 26: Line 26:
 
<'' 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=

Revision as of 13:15, 16 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 - Versions 4.0.14 and higher:

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:

  • ListeningDevice is permanent and bound to the port. It can be closed only when listener is terminated.
  • AcceptingDevice[x] is created each time a listener creates new server task.
  • Application cannot close AcceptingDevice[x] when it is accepting.

See Also