swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax     Other Library Functions  
function  

tcp.create-service

 
 

Library: TCP/IP client and server support (OMTCP)
Import: omtcp.xmd
Return type: tcp-service

Returns:


Declaration

define external tcp.service function tcp.create-service
     on         value integer PortNum           optional
     queue-size value integer ListenQueueSize   optional

or

define external tcp.service function tcp.create-service
     descriptor value integer ListenSocketDescriptor  optional
     queue-size value integer ListenQueueSize         optional

Argument definitions

PortNum
is the port the service is to be created on.
ListenSocketDescriptor
is a file descriptor for an already created socket.
ListenQueueSize
is the number of connection requests that will be queued for acceptance. The default value is 5.


Purpose

Use tcp.create-service in a server program to create a TCP service port to listen on for incoming service requests.

Requirements

You can specify either PortNum or the ListenSocketDescriptor, but not both (else external exception TCP22).

If ListenSocketDescriptor is specified it must be 0 or greater (else external exception TCP24).

If ListenQueueSize is specified it must be an integer from 1 to 1024 (else external exception TCP23).

Usage Notes

The maximum ListenQueueSize is operating system dependent. If the maximum queue size for a socket on your operating system is less than the value specified for ListenQueueSize, no exception will be thrown.

If PortNum is specified a listening socket descriptor is created at the specified port.

If neither PortNum or ListenSocketDescriptor is specified an available port is chosen. You can discover the number of this port using the tcp.port function.

If ListenSocketDescriptor is specified it is assumed to be a valid listening socket. This means that a socket was created using an external function library function prior to calling to tcp.create-service.

Example #1


  import "omtcp.xmd" prefixed by tcp.
  
  process
     local tcp.service DemoService
  
     set DemoService to tcp.create-service on 5600

Example #2


  import "omtcp.xmd" prefixed by tcp.
  process
     local tcp.service DemoService
     local integer port
  
     set DemoService to tcp.create-service
     set port to tcp.port of DemoService
     output "The selected service port for omdemo-service is %d(port)%n"

    Related Syntax
   tcp.port
   tcp.accept-connection
   tcp.destroy-service
 
  Other Library Functions
   tcp.accept-connection
   tcp.connect
   tcp.connection
   tcp.create-service
   tcp.destroy-service
   tcp.disconnect
   tcp.end-delimited
   tcp.get-string
   tcp.is-connected
   tcp.multi-packet
   tcp.omtcp-version
   tcp.peer-ip
   tcp.peer-name
   tcp.port
   tcp.put-string
   tcp.reader
   tcp.service
   tcp.set-buffering
   tcp.single-packet
   tcp.terminate-reader
   tcp.wait-for-input
   tcp.writer
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:27:39 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.